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

Unit tests appear to be broken - recent merge? #523

Closed
stleary opened this issue Jun 3, 2020 · 10 comments · Fixed by #525 or #527
Closed

Unit tests appear to be broken - recent merge? #523

stleary opened this issue Jun 3, 2020 · 10 comments · Fixed by #525 or #527

Comments

@stleary
Copy link
Owner

stleary commented Jun 3, 2020

Top priority - get the unit tests working again. Needs to be working by EOD 6/3/2020
Unit tests now working for gradle 6.3 with Java 1.8, and maven 3.2.3 with Java 1.8.

Before any more PRs can be accepted:

  • Code and unit tests have to compile and execute using Java 1.6 - 1.8 1.8 completed. 1.6 and 1.7 test successfully in Eclipse. Gradle properties require 1.8, maven hardcodes 1.7. Completed sufficiently for now
  • Gradle builds need to work, with documentation suitable for new developers on how to get it running. Completed sufficently for now, docs pending
  • Maven builds need to work, with documentation suitable for new developers on how to get it running. Completed sufficently for now, docs pending
  • Eclipse builds need to work, with documentation. Optionally, if anyone has gotten this to work with IntelliJ, that would be welcome as well. Completed, docs pending
  • Documentation for how a person will little prior experience can manually find, compile, and use the lib files.
  • Restore unit tests in JSONObjectTest:
    • testSingletonBean()
    • testSingletonEnumBean()
@johnjaylward
Copy link
Contributor

@stleary the changes made here https://github.com/viveksacademia4git/JSON-java/blob/master/.github/workflows/maven.yml

provides an interface like this: https://github.com/viveksacademia4git/JSON-java/actions/runs/123544252

For every PR, it's automated and we can confirm if test cases are failing before merging them.

I think taking the changes from @viveksacademia4git would be a good idea for PR requests going forward.

@viveksacademia4git
Copy link
Contributor

Hello @stleary and @johnjaylward,

I was just going through this issue and I discovered a strange phenomenon, and I guess this issue is focusing on that.
If you execute the mvn test command it exhibits that there are total number of 315 tests, as displayed in the pipeline/action stage: test:line9053.

But upon executing the tests from Eclipse, be it JUnit-Test or Coverage, the total number of unit-tests executed is exactly double i.e. 630.

image

Upon placing the debug point on one of the 2 failing tests, on JSONObjectTest.java#L3004, I encountered that the respective test is executing twice and there are 2 instances of objects within the JSONObject (which I understand why), which is forcing the test to fail. I find the execution of all the tests twice very strange.

@johnjaylward
Copy link
Contributor

johnjaylward commented Jun 3, 2020

yeah, the main issue there I believe is due to the way we configure the tests. When run from the command line, all the tests are only run once. When run in eclipse, it runs the tests twice within the same process scope, so those 2 singleton tests fail as they expect to be only called once.

I believe deleting the "TestRunner.java" file would correct it, but I haven't verified that.

@johnjaylward
Copy link
Contributor

ok, deleting both TestRunner.java and JUnitTestSuite.java solves the eclipse problem. I haven't verified command line testing works yet with those removed.

@viveksacademia4git
Copy link
Contributor

It works everywhere now!

@johnjaylward
Copy link
Contributor

johnjaylward commented Jun 3, 2020

confirmed. mvn test runs just 314 tests with both those files removed, and Eclipse works fine. I did not verify gradle as I don't have a system gradle installed and this project doesn't include the gradle wrapper.

@viveksacademia4git
Copy link
Contributor

I had an issue with gradle command, but everything works fine after making few changes.

Please check the commit viveksacademia4git/JSON-java -> commit-2fc1934

$ sh ./gradlew clean

BUILD SUCCESSFUL in 632ms
1 actionable task: 1 executed



$ sh ./gradlew assemble

> Task :compileJava
warning: [options] source value 7 is obsolete and will be removed in a future release
warning: [options] target value 7 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
3 warnings

BUILD SUCCESSFUL in 852ms
2 actionable tasks: 2 executed



$ sh ./gradlew check

> Task :compileTestJava
warning: [options] source value 7 is obsolete and will be removed in a future release
warning: [options] target value 7 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
3 warnings

> Task :test
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.mockito.cglib.core.ReflectUtils$2 (file:/home/vivek/.m2/repository/org/mockito/mockito-core/1.9.5/mockito-core-1.9.5.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of org.mockito.cglib.core.ReflectUtils$2
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.3/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 2s
4 actionable tasks: 3 executed, 1 up-to-date



$ sh ./gradlew build

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.3/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 746ms
5 actionable tasks: 5 up-to-date

@johnjaylward
Copy link
Contributor

I cherry picked your changes and was able to use the gradle wrapper, but I don't think the changes to the build.gradle were needed. I reverted that file, and was still able to run the tests using the command ./gradlew clean test check

@viveksacademia4git
Copy link
Contributor

viveksacademia4git commented Jun 3, 2020

Oh Nice!
Meanwhile, I renamed the maven.yml to pipeline.yml because it is not restricted to executing the maven scripts anymore and also contains commands to execute the gradle scripts.
And check out this pipeline executing both maven and gradle scripts.
I still have to figure out how does the CD works in GitHub.

@stleary
Copy link
Owner Author

stleary commented Jun 4, 2020

Reopen so that all pending issues can be tracked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants