[ https://issues.apache.org/jira/browse/SUREFIRE-2189?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Robert Važan updated SUREFIRE-2189: ----------------------------------- Description: There are sometimes reasons to put JUnit tests under src/main/java next to production code. Surefire cannot detect these tests and runs only tests under src/test/java. I tried to set testClassesDirectory to target/classes. That causes surefire to run tests under src/main/java, but then tests under src/test/java are ignored. Changing testClassesDirectory also causes weird module loading exceptions in a bigger project with more dependencies. If you are curious why anyone would put tests in production code, here are my reasons: # I want to run all tests in the background after the app starts in dev environment. Since the tests rarely fail, this lets me shorten edit-test-run cycle into edit-run cycle. # I want to visually annotate app UI that has associated tests. # I want to run tests in production environment as a sanity check. # I want to check compatibility between the app and its environment. This could be done with ordinary code, but structuring it as JUnit tests is convenient and results in clean code. I want to run these tests via surefire too to make sure they aren't already failing in dev environment. was: There are sometimes reasons to put JUnit tests under src/main/java next to production code. Surefire cannot detect these tests and runs only tests under src/test/java. I tried to set testClassesDirectory to target/classes. That causes surefire to run tests under src/main/java, but then tests under src/test/java are ignored. Changing testClassesDirectory also causes weird module loading exceptions in a bigger project with more dependencies. If you are curious why anyone would put tests in production code, here are my reasons: # I want to run all tests in the background after the app starts in dev environment. Since the tests rarely fail, this lets me shorten edit-test-run cycle into edit-run cycle. # I want to visually annotate app UI that has associated tests. # I want to run tests in production environment as a sanity check. # I want to check compatibility between the app and its environment. This could be done with ordinary code, but structuring it as JUnit tests is convenient and results in clean code. > Tests in src/main/java are not detected > --------------------------------------- > > Key: SUREFIRE-2189 > URL: https://issues.apache.org/jira/browse/SUREFIRE-2189 > Project: Maven Surefire > Issue Type: Bug > Components: JUnit 5.x support, Maven Surefire Plugin > Affects Versions: 3.1.2 > Environment: Java 17, with or without JPMS > Reporter: Robert Važan > Priority: Major > > There are sometimes reasons to put JUnit tests under src/main/java next to > production code. Surefire cannot detect these tests and runs only tests under > src/test/java. > I tried to set testClassesDirectory to target/classes. That causes surefire > to run tests under src/main/java, but then tests under src/test/java are > ignored. Changing testClassesDirectory also causes weird module loading > exceptions in a bigger project with more dependencies. > If you are curious why anyone would put tests in production code, here are my > reasons: > # I want to run all tests in the background after the app starts in dev > environment. Since the tests rarely fail, this lets me shorten edit-test-run > cycle into edit-run cycle. > # I want to visually annotate app UI that has associated tests. > # I want to run tests in production environment as a sanity check. > # I want to check compatibility between the app and its environment. This > could be done with ordinary code, but structuring it as JUnit tests is > convenient and results in clean code. I want to run these tests via surefire > too to make sure they aren't already failing in dev environment. -- This message was sent by Atlassian Jira (v8.20.10#820010)