sdaschner / jaxrs-analyzer

Creates REST documentation for JAX-RS projects
Apache License 2.0
319 stars 101 forks source link

Failing test #110

Open hindsholm opened 7 years ago

hindsholm commented 7 years ago

I am unable to build jaxrs-analyzer due to a failing test:

test(com.sebastian_daschner.jaxrs_analyzer.analysis.ProjectAnalyzerTest)`  Time elapsed: 1.357 sec  <<< FAILURE!
org.junit.ComparisonFailure: expected:<[rest]> but was:<[]>

This is on a fresh clone from master.

My setup should be up to date:

[morten@t430s] 15:21 $ mvn -v
Apache Maven 3.3.9 (NON-CANONICAL_2015-11-23T13:17:27+03:00_root; 2015-11-23T11:17:27+01:00)
Maven home: /opt/maven
Java version: 1.8.0_121, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-jdk/jre
Default locale: en_DK, platform encoding: UTF-8
OS name: "linux", version: "4.10.6-1-arch", arch: "amd64", family: "unix"`

The same test fails also on a similar setup on Windows 7.

Please let me know if I should provide more information.

rmpestano commented 7 years ago

Hi @hindsholm,

I've just tested here (just cloned master) and its all green, both via IDE and maven, here's my setup:

Apache Maven 3.3.9
Maven home: /usr/share/maven
Java version: 1.8.0_121, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-oracle/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.4.0-66-generic", arch: "amd64", family: "unix"

Anyone else experiencing this?

hindsholm commented 7 years ago

I also thought it was strange that nobody else had reported this, so it may be just me :) But on the other hand, I get the exact same error on both Linux and Windows and I also tried both OpenJDK and Oracle JDK, and I am running out of ideas of what to try...

sdaschner commented 7 years ago

That specific test is a concurrency error when running the ProjectAnalyzerTest and some other. I've excluded parallel tests to not run via Maven, do you use multiple threads in you mvn command?

Btw, we should also make the tests runnable in parallel (there is some static variable that needs to be modified which I can't remember right away...)

hindsholm commented 7 years ago

Thank you @sdaschner - your comment led me on the right track. I learned through some googling that since jaxrs-analyzer uses an older version (2.10) of surefire-plugin, you can ensure that tests are run sequentially by setting forkMode like in:

mvn -DforkMode=always clean install

and the project builds just fine.

With a newer Surefire you could actually specify this behavior through an annotation as described in the official docs:

Since of Surefire 2.18, you can apply the JCIP annotation @net.jcip.annotations.NotThreadSafe on the Java class of JUnit test (test class, Suite, Parameterized, etc.) in order to execute it in single Thread instance.

I'll close the issue since it has now been solved.

abstratt commented 7 years ago

@hindsholm @sdaschner I'd like to reopen this issue since it still occurs without the workaround (specifying -DforkMode=always). Can please one of you do that? (I don't have permission)

One fix would be to change the surefire configuration in the pom.xml to use that option. Another would be to adopt JCIP annotation. It is unfortunate that Surefire made it so hard to run tests sequentially. Parallel test running is a bad idea, as it introduces random variability (tests should always pass or always fail)...

jnorthrup commented 6 years ago

surefire has a ThreadSafe annotation, the specifics escape me. i used @Ignore

dizzzz commented 5 years ago

I confirm, this test is still failing (java8, mvn 3.5.5)

Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 1.052 sec <<< FAILURE!
test(com.sebastian_daschner.jaxrs_analyzer.analysis.ProjectAnalyzerTest)  Time elapsed: 1.051 sec  <<< FAILURE!
org.junit.ComparisonFailure: expected:<[rest]> but was:<[]>
        at org.junit.Assert.assertEquals(Assert.java:115)
        at org.junit.Assert.assertEquals(Assert.java:144)
        at com.sebastian_daschner.jaxrs_analyzer.analysis.ProjectAnalyzerTest.test(ProjectAnalyzerTest.java:80)

config:

Java version: 1.8.0_201, vendor: Oracle Corporation, runtime: C:\Localdata\ProgramFiles\Java\jdk1.8.0_201\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
Picked up _JAVA_OPTIONS: -Djava.net.preferIPv4Stack=true
sichgeis commented 4 years ago

@sdaschner : I have created a PR to fix this concurrency issue with running the tests. I would be glad to support the project. That PR is #196