execute the same test multiple times using [junit-platform-console-standalone-1.9.2.jar] - junit5

I am using junit5 standalone platform launcher and I want to execute the same test class several times using the command line of junit-platform-console-standalone-1.9.2.jar.
I tried repeating (as per junit5 documentation) --select-class argument, i.e:
java -jar junit-platform-console-standalone-1.5.2.jar --select-class=com.pcbsys.nirvana.nJMS.JMSQueueTxSessionConsumerTest --select-class=com.pcbsys.nirvana.nJMS.JMSQueueTxSessionConsumerTest --include-engine=junit-vintage --include-engine=junit-jupiter -cp ...
This yields:
Test run finished after 67368 ms
[ 3 containers found ]
[ 0 containers skipped ]
[ 3 containers started ]
[ 0 containers aborted ]
[ 2 containers successful ]
[ 1 containers failed ]
[ 1 tests found ]
[ 0 tests skipped ]
[ 1 tests started ]
[ 0 tests aborted ]
[ 0 tests successful ]
[ 1 tests failed ]
I can see that the test is executed only once (it is a failing test).
I also tried
--select-iteration=class:com.pcbsys.nirvana.nJMS.JMSQueueTxSessionConsumerTest[2]
but this syntax aims at parametrized tests, so was not the right for me.
Any ideas what needs fixing?

Related

Is it necessary to root devices to be able to access scoped storage?

We are currently using AWS Device Farm for testing android applications. Using AWS device farm, first the apk is built. Then, the required artifacts are placed in the testing device's scoped storage. Then, the application is ran(which uses these artifacts).
Lately, I have been facing the following issue when trying to push the artifacts:
(Consider my app's package is "com.myapp")
[ 5%] /sdcard/Android/data/com.myapp/files/MyFolder/scripts.zip
[ 11%] /sdcard/Android/data/com.myapp/files/MyFolder/scripts.zip
[ 16%] /sdcard/Android/data/com.myapp/files/MyFolder/scripts.zip
[ 22%] /sdcard/Android/data/com.myapp/files/MyFolder/scripts.zip
[ 27%] /sdcard/Android/data/com.myapp/files/MyFolder/scripts.zip
[ 33%] /sdcard/Android/data/com.myapp/files/MyFolder/scripts.zip
[ 38%] /sdcard/Android/data/com.myapp/files/MyFolder/scripts.zip
[ 44%] /sdcard/Android/data/com.myapp/files/MyFolder/scripts.zip
[ 49%] /sdcard/Android/data/com.myapp/files/MyFolder/scripts.zip
[ 55%] /sdcard/Android/data/com.myapp/files/MyFolder/scripts.zip
[ 60%] /sdcard/Android/data/com.myapp/files/MyFolder/scripts.zip
[ 66%] /sdcard/Android/data/com.myapp/files/MyFolder/scripts.zip
[ 71%] /sdcard/Android/data/com.myapp/files/MyFolder/scripts.zip
[ 77%] /sdcard/Android/data/com.myapp/files/MyFolder/scripts.zip
[ 82%] /sdcard/Android/data/com.myapp/files/MyFolder/scripts.zip
[ 88%] /sdcard/Android/data/com.myapp/files/MyFolder/scripts.zip
[ 93%] /sdcard/Android/data/com.myapp/files/MyFolder/scripts.zip
[ 99%] /sdcard/Android/data/com.myapp/files/MyFolder/scripts.zip
[100%] /sdcard/Android/data/com.myapp/files/MyFolder/scripts.zip
adb: error: failed to copy 'scripts.zip' to '/sdcard/Android/data/com.myapp/files/MyFolder/scripts.zip': remote secure_mkdirs failed: Permission denied
on GOOGLE PIXEL 5 (UNLOCKED) OS 11
Whereas the same logic worked on a few set of devices:
SAMSUNG GALAXY S20 (UNLOCKED) 10
SAMSUNG GALAXY S9 (UNLOCKED) 9
The following command is run to push the scripts.zip file:
adb push scripts.zip /sdcard/Android/data/com.myapp/files/MyFolder/scripts.zip
I read a lot of articles about this error but all of them were using rooted device. Thus on running certain commands, they were able to fix it. In my case, aws cloud contains real device on which the testcases are run and thus rooting the device is not possible.
My requirement is to push the artifact into the scoped storage of my own application using cmd commands.
Thank you in advance.
The scoped storage location of your own app on Pixel devices is
/data/data/com.myapp/files
to copy a file into this folder you can copy it into a temporary location:
adb push scripts.zip /data/local/tmp/scripts.zip
then copy the uploaded file into the app's private location:
adb shell run-as com.myapp cp /data/local/tmp/scripts.zip .

junit 5 console launcher throwing an error "Caused by: java.lang.ClassNotFoundException"

I'm using the complied library of jars of a java project and trying to run a junit 5 test via console launcher. Same test works when i right click and run as junit test but via console launcher it throws the below error.
This is what i'm using to compile the program and it complies without errors
javac -encoding UTF8 -cp /abc/Junit/lib/*:/var/Unit/lib/* /abc/Unit/ /Junit/test/BuildTest.java
and this is how I run the tests
java -jar /abc/Junit/lib/junit-platform-console-standalone-1.6.0.jar --classpath /abc/Junit/lib/*:/abc/Unit/lib/*:/abc/Junit/test --include-classname ".*" --scan-classpath
This is error I'm getting
Thanks for using JUnit! Support its development at https://junit.org/sponsoring
.
+-- JUnit Jupiter [OK]
| '-- buildTests [X] com.build.Info
'-- JUnit Vintage [OK]
Failures (1):
JUnit Jupiter:buildTests
ClassSource [className = 'com.buildTests', filePosition = null]
=> java.lang.NoClassDefFoundError: com.build.VersionInfo
java.lang.Class.getDeclaredFields(Class.java:868)
org.junit.platform.commons.util.ReflectionUtils.getDeclaredFields(ReflectionUtils.java:1334)
org.junit.platform.commons.util.ReflectionUtils.findAllFieldsInHierarchy(ReflectionUtils.java:1092)
org.junit.platform.commons.util.ReflectionUtils.findFields(ReflectionUtils.java:1080)
org.junit.platform.commons.util.AnnotationUtils.findAnnotatedFields(AnnotationUtils.java:371)
[...]
Caused by: java.lang.ClassNotFoundException: com.build.VersionInfo
java.net.URLClassLoader.findClass(URLClassLoader.java:610)
java.lang.ClassLoader.loadClassHelper(ClassLoader.java:935)
java.lang.ClassLoader.loadClass(ClassLoader.java:880)
java.net.FactoryURLClassLoader.loadClass(URLClassLoader.java:1225)
java.lang.ClassLoader.loadClass(ClassLoader.java:863)
[...]
Test run finished after 73 ms
[ 3 containers found ]
[ 0 containers skipped ]
[ 3 containers started ]
[ 0 containers aborted ]
[ 2 containers successful ]
[ 1 containers failed ]
[ 1 tests found ]
[ 0 tests skipped ]
[ 0 tests started ]
[ 0 tests aborted ]
[ 0 tests successful ]
[ 0 tests failed ]
Finally, was able to figure out why the error is thrown. Issue was not giving the actual jar and using wild card while running the test. It has to be blah/lib/core.jar not blah/lib/*. Hope this helps someone in the future.

Why does my Bazel test report failure when all individual tests are passing?

When running my unit test (gtest) through Bazel, I'm seeing a failure reported. However, the logs indicate that my test is running successfully and passing.
Other tests in my project are passing and the only difference between the deviant test and the others is that the deviant test is multithreaded.
I've run the test binary found in bazel-bin by itself and it passes and returns successfully.
Bazel version:
Build label: 0.26.0
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Tue May 28 08:35:14 2019 (1559032514)
Build timestamp: 1559032514
Build timestamp as int: 1559032514
The relevant block in my BUILD file:
cc_test(
name = "DBControllerIntegration",
srcs = ["dbcontroller_integration_test.cc"],
deps = [
"//src:db_ctl_lib",
"//test/mocks:sstable_mock_lib",
"#boost//:filesystem",
"#com_google_protobuf//:protobuf",
"#glog//:glog",
"#googletest//:gtest_main",
],
copts = ["-std=c++17"],
)
Bazel test failure output:
>> bazel test //test:DBControllerIntegration --test_output=errors
INFO: Invocation ID: ccca8fa7-27a5-4c8c-badf-3f342934e4e5
INFO: Analysed target //test:DBControllerIntegration (0 packages loaded, 0 targets configured).
INFO: Found 1 test target...
FAIL: //test:DBControllerIntegration (see /home/tallen/.cache/bazel/_bazel_tallen/f087948e065d612174d90a43a5740198/execroot/diodb/bazel-out/k8-dbg/testlogs/test/DBControllerIntegration/test.log)
INFO: From Testing //test:DBControllerIntegration:
==================== Test output for //test:DBControllerIntegration:
Running main() from gmock_main.cc
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from DBControllerIntegrationTest
[ RUN ] DBControllerIntegrationTest.Basic
... <omitting my application's logs> ...
[ OK ] DBControllerIntegrationTest.Basic (4000 ms)
[----------] 1 test from DBControllerIntegrationTest (4000 ms total)
[----------] Global test environment tear-down
[==========] 1 test from 1 test case ran. (4001 ms total)
[ PASSED ] 1 test.
================================================================================
Target //test:DBControllerIntegration up-to-date:
bazel-bin/test/DBControllerIntegration
INFO: Elapsed time: 4.706s, Critical Path: 4.57s
INFO: 1 process: 1 processwrapper-sandbox.
INFO: Build completed, 1 test FAILED, 2 total actions
//test:DBControllerIntegration FAILED in 4.6s
/home/tallen/.cache/bazel/_bazel_tallen/f087948e065d612174d90a43a5740198/execroot/diodb/bazel-out/k8-dbg/testlogs/test/DBControllerIntegration/test.log
INFO: Build completed, 1 test FAILED, 2 total actions
Running the test binary by itself:
>> ./bazel-bin/test/DBControllerIntegration
Running main() from gmock_main.cc
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from DBControllerIntegrationTest
[ RUN ] DBControllerIntegrationTest.Basic
... <omitting my application's logs> ...
[ OK ] DBControllerIntegrationTest.Basic (4001 ms)
[----------] 1 test from DBControllerIntegrationTest (4001 ms total)
[----------] Global test environment tear-down
[==========] 1 test from 1 test case ran. (4001 ms total)
[ PASSED ] 1 test.
I would expect the Bazel test result to be reported as passing since the actual test is passing, but I'm seeing the test as failed.
This was resolved when gracefully terminating all threads spawned by my project.

NUnit sometimes ends with "unable to locate fixture"

The NUnit-console 2.6.3 sometimes prints out the following error message instead of running tests. Here is excerpt from my Jenkins test build logs:
00:05:02.982 Process 'nunit-console-x86' [PID 3684] has begun profiling.
00:05:03.698 NUnit-Console version 2.6.3.13283
00:05:03.698 Copyright (C) 2002-2012 Charlie Poole.
00:05:03.698 Copyright (C) 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov.
00:05:03.698 Copyright (C) 2000-2002 Philip Craig.
00:05:03.698 All Rights Reserved.
00:05:03.698
00:05:03.698 Runtime Environment -
00:05:03.701 OS Version: Microsoft Windows NT 6.1.7601 Service Pack 1
00:05:03.701 CLR Version: 2.0.50727.5485 ( Net 3.5 )
00:05:03.701
00:05:03.795 ProcessModel: Default DomainUsage: Single
00:05:03.795 Execution Runtime: net-3.5
00:05:33.886 Unable to locate fixture
00:05:33.895 Process 'nunit-console-x86' [PID 3684] has finished profiling.
It happens randomly. I do not change the test assembly or the NUnit configuration. I run NUnit via NCover, but the same problem repeats when I use NUnit alone from the command line.
After enabling the verbose logging in NUnit I noticed that the nunit-agent process prints out its first messages to the log more than half a minute after it was run by the nunit-console. I found out from the source code that nunit-console waits 30 seconds for the spawned nunit-agent process to register itself. Apparently something delays loading nunit-agent so the timeout is hit in nunit-console causing the "Unable to locate fixture ". The nunit-agent process is still running after that and I have to kill it manually.
NUnit-console log:
InternalTrace: Initializing at level Verbose
09:14:08.992 Info [ 1] Runner: NUnit-console.exe starting
09:14:09.006 Debug [ 1] ServiceManager: Added SettingsService
09:14:09.006 Debug [ 1] ServiceManager: Added DomainManager
09:14:09.007 Debug [ 1] ServiceManager: Added ProjectService
09:14:09.007 Debug [ 1] ServiceManager: Added AddinRegistry
09:14:09.007 Debug [ 1] ServiceManager: Added AddinManager
09:14:09.007 Debug [ 1] ServiceManager: Added TestAgency
09:14:09.008 Info [ 1] ServiceManager: Initializing SettingsService
09:14:09.008 Info [ 1] ServiceManager: Initializing DomainManager
09:14:09.008 Info [ 1] ServiceManager: Initializing ProjectService
09:14:09.008 Info [ 1] ServiceManager: Initializing AddinRegistry
09:14:09.008 Info [ 1] ServiceManager: Initializing AddinManager
09:14:09.009 Debug [ 1] ServiceManager: Request for service IAddinRegistry satisfied by AddinRegistry
09:14:09.017 Info [ 1] ServiceManager: Initializing TestAgency
09:14:09.041 Debug [ 1] ServiceManager: Request for service ProjectService satisfied by ProjectService
09:14:09.054 Debug [ 1] RuntimeFrameworkSelector: Current framework is net-3.5
09:14:09.054 Debug [ 1] RuntimeFrameworkSelector: No specific framework requested
09:14:09.054 Debug [ 1] ServiceManager: Request for service ISettings satisfied by SettingsService
09:14:09.058 Debug [ 1] RuntimeFrameworkSelector: Assembly D:\Jenkins\jobs\Job1\GreyBoxTests\bin\Debug\GreyBoxTests.dll uses version 4.0.30319
09:14:09.064 Debug [ 1] ServiceManager: Request for service TestAgency satisfied by TestAgency
09:14:09.065 Debug [ 1] RuntimeFrameworkSelector: Test will use net-4.0 framework
09:14:09.066 Info [ 1] ProcessRunner: Loading GreyBoxTests.dll
09:14:09.067 Info [ 1] TestAgency: Getting agent for use under net-4.0
09:14:09.070 Debug [ 1] TestAgency: Using nunit-agent at c:\Program Files (x86)\NUnit 2.6.3\bin\nunit-agent-x86.exe
09:14:09.091 Info [ 1] TestAgency: Launched Agent process 7240 - see nunit-agent_7240.log
09:14:09.091 Info [ 1] TestAgency: Command line: "c:\Program Files (x86)\NUnit 2.6.3\bin\nunit-agent-x86.exe" 65bc321d-e7dc-4a98-81e6-919b87d5c783 tcp://127.0.0.1:56614/TestAgency
09:14:09.091 Debug [ 1] TestAgency: Waiting for agent {65bc321d-e7dc-4a98-81e6-919b87d5c783} to register
09:14:39.091 Info [ 1] Runner: NUnit-console.exe terminating
NUnit-agent log:
InternalTrace: Initializing at level Verbose
09:14:41.859 Info [ 1] NUnitTestAgent: Agent process 7240 starting
09:14:41.876 Info [ 1] NUnitTestAgent: Running under version 4.0.30319.18444, Net 4.5
09:14:41.876 Info [ 1] NUnitTestAgent: Adding Services
09:14:41.876 Debug [ 1] ServiceManager: Added SettingsService
09:14:41.877 Debug [ 1] ServiceManager: Added ProjectService
09:14:41.877 Debug [ 1] ServiceManager: Added DomainManager
09:14:41.877 Debug [ 1] ServiceManager: Added AddinRegistry
09:14:41.877 Debug [ 1] ServiceManager: Added AddinManager
09:14:41.877 Info [ 1] NUnitTestAgent: Initializing Services
09:14:41.878 Info [ 1] ServiceManager: Initializing SettingsService
09:14:41.878 Info [ 1] ServiceManager: Initializing ProjectService
09:14:41.878 Info [ 1] ServiceManager: Initializing DomainManager
09:14:41.878 Info [ 1] ServiceManager: Initializing AddinRegistry
09:14:41.878 Info [ 1] ServiceManager: Initializing AddinManager
09:14:41.879 Debug [ 1] ServiceManager: Request for service IAddinRegistry satisfied by AddinRegistry
09:14:41.906 Info [ 1] NUnitTestAgent: Connecting to TestAgency at tcp://127.0.0.1:56614/TestAgency
09:14:41.907 Info [ 1] NUnitTestAgent: Starting RemoteTestAgent
09:14:41.908 Info [ 1] RemoteTestAgent: Agent starting
Any NUnit experts could help me with this?
Potential workaround, suggested by Charlie in that Google Groups thread:
One way to avoid this is to stop using the agent. Change the config file
(nunit-console-x86.exe.config) to use the 4.0 CLR before the 2.0 CLR. Then
the test will run in the same process and no agent will be created.
I have confirmed that adding <supportedRuntime version="v4.0.30319" /> inside <startup> in the nunit-console.exe.config file (or nunit-console-x86.exe.config), and removing <supportedRuntime version="v2.0.50727" (if present) does cause my tests to run without spawning an nunit-agent.exe process. I have not confirmed whether that fixes the error "unable to locate fixture" in my case, but the OP (krzysiek_w) did confirm it in the same thread:
I was not aware of the possibility to run tests in nunit-console without the nunit-agent. After setting the supported framework in the nunit-console config file, the tests execute without creating the separate process which completely fixes the problem.
As an additional note, the option /trace=Verbose can be passed to NUnit to get more info, as krzysiek_w did in that thread. For me, those logs are output to C:\Users\(myuser)\AppData\Local\NUnit\logs.

RabbitMQ configuring dynamic shovel error - 'component shovel not found'

I'm trying to configure a dynamic shovel on RabbitMQ 3.2.3 after installing the Shovel plugin. However, when I run the following command:
rabbitmqctl set_parameter shovel test-shovel '{"src-uri": "amqp://", "src-queue": "queueName", "dest-uri": "amqp://user:password#host", "dest-queue": "queueName"}'
...I get this error message:
Error: Validation failed
component shovel not found
The plugin appears to be installed correctly. If I run:
rabbitmq-plugins list
...I get:
[e] amqp_client 3.2.3
[ ] cowboy 0.5.0-rmq3.2.3-git4b93c2d
[ ] eldap 3.2.3-gite309de4
[e] mochiweb 2.7.0-rmq3.2.3-git680dba8
[ ] rabbitmq_amqp1_0 3.2.3
[ ] rabbitmq_auth_backend_ldap 3.2.3
[ ] rabbitmq_auth_mechanism_ssl 3.2.3
[ ] rabbitmq_consistent_hash_exchange 3.2.3
[ ] rabbitmq_federation 3.2.3
[ ] rabbitmq_federation_management 3.2.3
[ ] rabbitmq_jsonrpc 3.2.3
[ ] rabbitmq_jsonrpc_channel 3.2.3
[ ] rabbitmq_jsonrpc_channel_examples 3.2.3
[E] rabbitmq_management 3.2.3
[e] rabbitmq_management_agent 3.2.3
[ ] rabbitmq_management_visualiser 3.2.3
[ ] rabbitmq_mqtt 3.2.3
[E] rabbitmq_shovel 3.2.3
[E] rabbitmq_shovel_management 3.2.3
[ ] rabbitmq_stomp 3.2.3
[ ] rabbitmq_tracing 3.2.3
[e] rabbitmq_web_dispatch 3.2.3
[ ] rabbitmq_web_stomp 3.2.3
[ ] rabbitmq_web_stomp_examples 3.2.3
[ ] rfc4627_jsonrpc 3.2.3-git5e67120
[ ] sockjs 0.3.4-rmq3.2.3-git3132eb9
[e] webmachine 1.10.3-rmq3.2.3-gite9359c7
Also, if I run:
rabbitmqctl eval 'rabbit_shovel_status:status().'
...I get:
[]
...done.
Any ideas?! Thanks in advance!
Looks like dynamic shovels were added in 3.3.0, doh! We're still on 3.2.3.
http://www.rabbitmq.com/release-notes/README-3.3.0.txt
Ok,
Typically this behavior is when you install a plug-in and you don't restart RabbitMQ server.
Restart RMQ is mandatory.
This can also occur due to a race condition in RMQ versions prior to 3.8.6. Until 3.8.6, loading static definitions could happen before plugins were activated, causing this validation error. For more information, see GitHub issue rabbitmq/rabbitmq-server#2384.