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

Fix for issue 2994 - unable to run JUnit tests locally #3255

Closed
wants to merge 1 commit into from

Conversation

LeoNerdoG
Copy link
Contributor

I have changed the category for running pure JUnit tests. Before this user could only run
the tests with command "mvn test -Dgroups='org.eclipse.kapua.test.junit.JUnitTests'", but
this changed, when this category got moved to qa/markers/...
Instead of using this default category for running JUnit tests, I have added a profile ("junitTests")
that enable developers and testers to run tests in Terminal on local machine with command:
"mvn test -PjunitTests".

This is the same as running tests with command "mvn test -Dgroups='org.eclipse.kapua.qa.markers.Categories$junitTests'",
but is much shorter and therfore easier to executed.
I recommend running this command prior to every push/PR to see, if everything is OK.

I have added ony one category in "qa/markers" module ("junitTests"), but I will also add one for running cucumber unit
tests and one for running cucumber integration tests later.

I have deleted a "unit" test that has been in "console" module for a long period of time, but it does nothing
and should actually not be there anyway:
deleted kapua/console/module/api/src/test/java/org/eclipse/kapua/app/console/module/api/test/SplitTooltipStringTest.java

POMs changed:

  • root kapua pom.xml
  • qa/integration/pom.xml
  • github actions yml file

Related Issue
this fixes issue #2994.

Description of the solution adopted
This is a fairly simpel solution, I only modified the Category for running unit tests, POMs (added "junitTests" profile) and GHA yaml file, becasuse category has been changed.

Any side note on the changes made
RunTests.md file has also been updated (with new command and some minor syntax errors).

@nezau-ct , @sonja-ct Can you please checkout this branch and run the tests locally on your machines with command "mvn test-PjunitTests" and report if the results are OK? Tests should be running for a couple of minutes (on my machine it takes 5 minutes, it may take more on your machines).

@Coduz can you please check the PR and merge it when you have time? Thanks!

Signed-off-by: Leonardo Gaube leonardo.gaube@endava.com

@codecov
Copy link

codecov bot commented Feb 24, 2021

Codecov Report

Merging #3255 (e53f248) into develop (3389a91) will increase coverage by 14.54%.
The diff coverage is n/a.

Impacted file tree graph

@@              Coverage Diff               @@
##             develop    #3255       +/-   ##
==============================================
+ Coverage      39.89%   54.43%   +14.54%     
- Complexity       694      785       +91     
==============================================
  Files           1455     1455               
  Lines          29749    29749               
  Branches        2498     2498               
==============================================
+ Hits           11867    16195     +4328     
+ Misses         16956    12638     -4318     
+ Partials         926      916       -10     
Impacted Files Coverage Δ Complexity Δ
...ransport/mqtt/pooling/PooledMqttClientFactory.java 50.00% <0.00%> (-11.91%) 0.00% <0.00%> (ø%)
...ore/plugin/authentication/AuthenticationLogic.java 73.75% <0.00%> (-11.25%) 0.00% <0.00%> (ø%)
...nnection/internal/DeviceConnectionCreatorImpl.java 93.10% <0.00%> (-6.90%) 0.00% <0.00%> (ø%)
...plugin/authentication/UserAuthenticationLogic.java 76.78% <0.00%> (-6.25%) 0.00% <0.00%> (ø%)
...obDeviceManagementOperationManagerServiceImpl.java 73.17% <0.00%> (-6.10%) 13.00% <0.00%> (-1.00%)
...a/org/eclipse/kapua/transport/mqtt/MqttClient.java 51.21% <0.00%> (-4.88%) 0.00% <0.00%> (ø%)
...lipse/kapua/kura/simulator/MqttAsyncTransport.java 52.77% <0.00%> (-2.78%) 0.00% <0.00%> (ø%)
...atch/persistence/jpa/JpaExecutionInstanceData.java 87.80% <0.00%> (-2.44%) 22.00% <0.00%> (-1.00%)
.../broker/core/plugin/KapuaSecurityBrokerFilter.java 75.42% <0.00%> (+0.57%) 0.00% <0.00%> (ø%)
...se/kapua/commons/event/jms/JMSServiceEventBus.java 23.68% <0.00%> (+0.87%) 0.00% <0.00%> (ø%)
... and 382 more

@LeoNerdoG LeoNerdoG force-pushed the fix-issue2994 branch 2 times, most recently from 5f23fa9 to 7a05fe7 Compare February 26, 2021 11:39
Copy link
Contributor

@Coduz Coduz left a comment

Choose a reason for hiding this comment

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

There are some things to change and also why there are plenty of test that have been removed?

@LeoNerdoG
Copy link
Contributor Author

Hey @Coduz,
I have resolved the two things you commented.
The reaseon, why I deleted some tests are:

  1. They are somehow duplicated and could be deleted or
  2. System.setProperty was not working "properly" and we had failing tests when running in the terminal.

The problem is, that IntelliJ has a different runner than e.g. GHA or Terminal. Because of this, some of the tests were failing when running locally (but not failing when running on Travis, GHA, IntelliJ or Eclipse). By removing them, we are not losing anything, as they should not be there in the first place (tests should always be successfull, no matter how they are run).

If this is not OK, I can try and find a different solution.

I have changed the category for running pure JUnit tests. Before this user could only run
the tests with command "mvn test -Dgroups='org.eclipse.kapua.test.junit.JUnitTests'", but
this changed, when this category got moved to qa/markers/...
Instead of using this default category for running JUnit tests, I have added a profile ("junitTests")
that enable developers and testers to run tests in Terminal on local machine with command:
"mvn test -PjunitTests".

This is the same as running tests with command "mvn test -Dgroups='org.eclipse.kapua.qa.markers.Categories$junitTests'",
but is much shorter and therfore easier to executed.
I recommend running this command prior to every push/PR to see, if everything is OK.

I have added ony one category in "qa/markers" module ("junitTests"), but I will also add one for running cucumber unit
tests and one for running cucumber integration tests later.

I have deleted a "unit" test that has been in "console" module for a long period of time, but it does nothing
and should actually not be there anyway:
deleted kapua/console/module/api/src/test/java/org/eclipse/kapua/app/console/module/api/test/SplitTooltipStringTest.java

POMs changed:
 - root kapua pom.xml
 - qa/integration/pom.xml
 - github actions yml file

RunTests.md file has also been updated (with new command and some minor syntax errors).

Signed-off-by: Leonardo Gaube <leonardo.gaube@endava.com>
@nezau-ct
Copy link
Contributor

nezau-ct commented Mar 5, 2021

I have run it on Ubuntu 18.04.5 and the tests finished successfully.

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

Successfully merging this pull request may close these issues.

3 participants