How can you pass "parallel" and "forkCount" properties to testNG using the maven command line?
According to the documentation:
parallel
(TestNG provider) When you use the parallel attribute, TestNG will try to run all your test methods in separate threads, except for methods that depend on each other, which will be run in the same thread in order to respect their order of execution.
User property is: parallel.
forkCount
User property is: forkCount.
So you can use them like:
mvn test -Dparallel=<value> -DforkCount=<value>
Related
I am trying to setup a Jenkins pipeline to trigger builds using gradle for multiple environments.My requirement is that the artifacts produced when I run gradlew clean build should produce artifacts with name indicating the environment for which the pipeline was run. Example my-application-dev.jar
The value of the environment would be selected by the user when build will be triggered.
What is the optimal way to achieve this ? Does build allow to configure any such property via command line or do I need to define a task in my build.gradle and define properties within that task for which I will pass value from command line
There are basically two ways.
The first one is to pass these naming-relevant pieces of information to the gradlew process, e.g. via -D or -P properties.
Then you need the Gradle build to be aware of these parameters and craft the artifact names it produces accordingly.
The second one is arguably better and more contained. You simply rename the artifacts produced by the gradlew command after it completes, in the Jenkinsfile. This works well if the pipeline decides what to do with these artifacts (e.g. publish to a repository) as opposed to the gradle script doing it (in which case you would most likely be better off using the first method).
How to run multiple methods present in different classes on mvn command line
referred How to run multiple test classes or test methods using Maven?
doesn't work for multiple method present in different class
Tried with below line
mvn -Dtest=testclass#method1, -Dtest=testclass2#method1 test
I am trying to configure two different gradle test tasks that essentially just set some values and then run the built-in test task. I have read the gradle documentation and have been searching for a few hours with no luck. I'm guessing I just don't know how to word this question properly to find anything.
The scenario is that we have selenium tests that we might want to run locally or remotely. If we run them locally we want to configure how many threads it uses, and if we run them remotely we want to set a much higher number of threads and also a system property so that the test runner knows to run remotely.
Essentially here's what I'd like to do:
task testLocal {
maxParallelForks = 2
// now run the built-in test task
}
task testRemote {
maxParallelForks = 4
systemProperties "geb.env": "winxp-firefox"
// now run the built-in test task
}
Ideally I'd also like to be able to pass all the same arguments that the test task supports on the command line, like:
gradle testLocal --tests com.domain.tests.package*
What is the proper way to handle this scenario with gradle?
The proper way to handle this is to have two Test tasks. You'd typically use (and configure) the Java plugin's test task for the local testing, and additionally declare and configure a second testRemote task (task testRemote(type: Test) { ... }). (There is no way to "wrap" a task, or "call" a task from another task.)
I am running gradle to run the tests from Windows command line. What I do to run a single test is:
gradlew.bat chromeTest -DchromeTest.single=test1Spec
or for all the tests:
gradlew.bat chromeTest
If I try to run only two test classes like this:
gradlew.bat chromeTest -DchromeTest=test1Spec,test2Spec--info
then gradle starts to run all the tests.
What I need: is to run only 2 or 3 Groovy classes. To be specific, neither one nor all. Any help would be really beneficial! Sorry, for reposting this question again.
-DtestTaskName supports wildcards such as Test*Spec or foo.bar.*Spec, but is limited to a single pattern. If you need support for multiple patterns, you'll have to implement your own command line parameter (which in the simplest case means reading a system property) and use that to configure Test#include or Test#getFilter. (See Test in the Gradle Build Language Reference for details.)
Gradle 1.10 introduced --tests as a replacement for -DtestTaskName, but again, only one pattern is supported.
Are there any form to run unit test with surefire in parallel but by module? For example, we are using build in parallel by defining number of threads. Can we apply this techniques by defining number of threads to execute test in parallel by module. For example, firstly, the project is compiled. Secondly, we can use compiled project for run our tests by following form: mvn -T 4 test?
There is a different between running the build parallelized and the tests parallelized. The first one is done by using the -T option but the test can be configured in maven-surefire-plugin.