Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CAMEL-20522: camel-test - CamelTestSupport does not call tearDown for… #13392

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -65,8 +65,6 @@
import org.apache.camel.util.StringHelper;
import org.apache.camel.util.TimeUtils;
import org.apache.camel.util.URISupport;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestInstance.Lifecycle;
import org.junit.jupiter.api.extension.AfterAllCallback;
import org.junit.jupiter.api.extension.AfterEachCallback;
Expand Down Expand Up @@ -140,11 +138,13 @@ public long timeTaken() {
public void beforeEach(ExtensionContext context) throws Exception {
currentTestName = context.getDisplayName();
globalStore = context.getStore(ExtensionContext.Namespace.GLOBAL);
setUp();
Copy link
Contributor

@orpiske orpiske Mar 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should rename this base method. IMHO, it can be very confusing to have this method named as setup and not running automatically as part of the BeforeEach.

I base this on the reasoning that the name may imply the former way of setting up tests from JUnit 4.

Wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah we have not found the best solution for this. This PR was just to show that its broken now, and that to make sure junit invokes the setup/teardown correctly we need more work.

}

@Override
public void afterEach(ExtensionContext context) throws Exception {
DefaultCamelContext.clearOptions();
tearDown();
}

@Override
Expand Down Expand Up @@ -341,7 +341,6 @@ public void setCamelContextService(Service service) {
THREAD_SERVICE.set(camelContextService);
}

@BeforeEach
public void setUp() throws Exception {
LOG.info(SEPARATOR);
LOG.info("Testing: {} ({})", currentTestName, getClass().getName());
Expand Down Expand Up @@ -563,7 +562,6 @@ private boolean isRouteCoverageEnabled() {
return System.getProperty(ROUTE_COVERAGE_ENABLED, "false").equalsIgnoreCase("true") || isDumpRouteCoverage();
}

@AfterEach
public void tearDown() throws Exception {
long time = watch.taken();

Expand Down
Expand Up @@ -20,15 +20,13 @@
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.test.junit5.CamelTestSupport;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.apache.camel.test.junit5.TestSupport.deleteDirectory;

public class IsMockEndpointsFileTest extends CamelTestSupport {

@Override
@BeforeEach
public void setUp() throws Exception {
deleteDirectory("target/input");
deleteDirectory("target/messages");
Expand Down