I’m getting the same problem this user was, except...
# kotest
s
I’m getting the same problem this user was, except I’m not using junit 4. I have excluded all junit 4 dependencies from my classpath (except it seems that kotest itself depends on junit 4 through the
kotest-runner-junit5-jvm
dependency), and yet kotest is not picking up any specs. https://kotlinlang.slack.com/archives/CT0G9SD7Z/p1679224817992859 To be a bit more clear, it seems to see the spec, but then not execute it.
Copy code
[INFO] Running com.sunrun.pricing.communitypricing.PrintDrlTest
ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.199 s - in com.sunrun.pricing.communitypricing.PrintDrlTest
``` I’m guessing this is because I’m using testcontainers elsewhere in my project (not in kotest) and so that is pulling in junit 4? The documentation around this is quite unclear. Am I forced to use junit 4 if I have a single junit4 dependency on my classpath, even if it’s coming from kotest itself?
a
can you share what dependencies you’ve added, and which you’ve excluded?
l
I've used test containers with Kotest and Junit 5 with no problems before. I also believe it's some dependency issues
s
dependencytree.txt
dependencies.xml
a
thanks
I don’t see the
maven-surefire-plugin
in there?
s
oh i didn’t post the full pom. I’ve got the surefire plugin
a
(It’s been a while since I’ve used Maven so I’m just following along with the Kotest instructions https://kotest.io/docs/quickstart)
s
Copy code
<plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${surefire-plugin.version}</version>
                <configuration>
                    <systemPropertyVariables>
                        <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
                        <quarkus.log.level>INFO</quarkus.log.level>
                        <maven.home>${maven.home}</maven.home>
                    </systemPropertyVariables>
                </configuration>
            </plugin>
that’s what we’re using.
but yeah, I have triple checked the directions. I’ve been using kotest for years but just recently started using testcontainers and I just noticed that the kotest tests are no longer running so I definitely think it’s related.
Maven Surefire and Maven Failsafe can run JUnit 4 based tests alongside Jupiter tests as long as you configure test scoped dependencies on JUnit 4 and the JUnit Vintage TestEngine implementation similar to the following
s
yeah I know I can add the vintage engine, but I’m not using any junit4 tests. Unless it’s testcontainers that’s forcing that?
a
and I think you might want
kotlin-test-junit5
instead of
kotlin-test-junit
?
ooh I see
s
think smart I didn’t realize there was a different kotlin-test dependency
let me try that.
a
I’m not super familiar with the kotlin-test dependencies, and I think there’s some Gradle magic which means sometimes one gets substituted for the other depending on the test task configuration
s
hm. changing for the kotlin-test-junit5 didn’t work. Let me try seeing if adding the vintage engine causes the tests to start running. that would help diagnose I think.
a
While Testcontainers is tightly coupled with the JUnit 4.x rule API
https://www.testcontainers.org/test_framework_integration/junit_5/ I think that JUnit 4 is required for TestContainers…
s
oh
Since this module has a dependency onto JUnit Jupiter and on Testcontainers core, which has a dependency onto JUnit 4.x, projects using this module will end up with both, JUnit Jupiter and JUnit 4.x in the test classpath.
so I will have to add the vintage engine.
well that’s probably the answer then.
I’ll try that. I have to head to a doctor’s appt though. I’ll be back in a bit.
nope. didn’t work. now it’s just running twice…
sorry, it’s saying it’s running twice, but it’s not actually
Copy code
[INFO] Running com.sunrun.pricing.communitypricing.PrintDrlTest
[INFO] Running com.sunrun.pricing.communitypricing.PrintDrlTest
ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.971 s - in com.sunrun.pricing.communitypricing.PrintDrlTest
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.058 s - in com.sunrun.pricing.communitypricing.PrintDrlTest
hm. so actually, the test is running. It’s just not showing as actually run. I completely misunderstood what was happening. Why is it not reporting as having run?
a
my guess is that the JUnit dependencies need some straightening out, and that there’s multiple JUnit runners that are interfering with each other
s
hm….
a
your POM looked pretty large, and there’s lots of test config. What might help is splitting out the integration tests into a separate subproject?
s
yeah I might have to do that. not sure how quarkus will deal with that though… this is what threw me off. maven thinks it’s failing to run, even if it’s actually running. I added some gibberish logging.
Copy code
[INFO] Running com.sunrun.pricing.communitypricing.PrintDrlTest
SDFLKJDKKDKKDKJDFkjdflkjdflkj
ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...
SDFLKJDKKDKKDKJDFkjdflkjdflkj
SDFLKJDKKDKKDKJDFkjdflkjdflkj
SDFLKJDKKDKKDKJDFkjdflkjdflkj
SDFLKJDKKDKKDKJDFkjdflkjdflkj
SDFLKJDKKDKKDKJDFkjdflkjdflkj
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.24 s - in com.sunrun.pricing.communitypricing.PrintDrlTest
[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  23.676 s
[INFO] Finished at: 2023-04-05T12:51:51-06:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.1:test (default-test) on project community-price: No tests were executed!  (Set -DfailIfNoTests=false to ignore this error.) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] <http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException>
we’re gonna be moving over to gradle hopefully soon enough so I might just ignore this for now.
a
I vaguely remember having the
Tests run: 0
problem a lot with Gradle Maven, and cursing at how hard it was to understand how to configure JUnit 4/5 vintage/Jupiter runners
there’s lots of hits on StackOverflow - copy and paste answers until something works?
s
haha ok well thanks for the help. I’d never seen that before.
113 Views