I was looking into how to improve overall execution time for JUnit test cases for my project. For the reference here that we are using the followings:
Maven 3.3.9
Junit 4.12
Maven Surefire Plugin 2.18.1
I was going through "Maven Surefire Plugin Parallel Test Execution" official documentation.
Could someone please clarify following doubts w.r.t. Surefire plugin configuration in pom.xml:
If useUnlimitedThreads attribute is set to true then is it recommended to provide threadcount attribute?
Based on above, what would happen if useUnlimitedThreads=true and threadcount=4 (for example). Would threadcount value still be considered while executing JUnit?
If we want to leverage "threadcount" along with useUnlimitedThreads=false then how to decide no. of threads? My perspective is that we should use useUnlimitedThreads=true with no threadcount configuration.
If we use configuration [useUnlimitedThreads=false and threadCount=4] then how to decide perCoreThreadCount boolean flag value? Default value is true. Also, how declaring it to false might impact execution time?
What is the significance of parallelOptimized attribute? How it might impact execution time?
Related
I'm starting to work on pipelines for jenkins (formerly workflow)
I'm using IntelliJ for an IDE
Is there a source of Documentation for GDSL or some way I can know what groovy is acceptable in the pipeline and what is not?
Also is there a way that I can test run the GDSL before having to check in my Jenkinsfile?
Is there a source of Documentation for GDSL
Yes, as of 1.13 you can download a GDSL schema from Snippet Generator and install it in IDEA. There are some aspects missing—for example step return types are not defined in this schema. Last I checked it also did not offer completion on, for example, known $class implementations for step; this information is available in the Snippet Generator UI and downloadable HTML reference documentation.
is there a way that I can test run the [script?] before having to check in my Jenkinsfile?
There is not currently an offline test feature; it would be tricky since everything in a Pipeline script is intended to be interacting with a live Jenkins service. (If you have other logic in there, it would be better factored out into external scripts in the language of your choice.)
As of 1.14 there is a Replay link you can use to iteratively test proposed changes before committing to Jenkinsfile, and you can use this from the CLI too.
I have a scenario where there are several independent jmx files, each of them has their own threadgroup etc. Using JMeter Ant script I can fire them all in sequence and collect the result in a jtl file. My challenge here is to do the same thing but fire off the tests in parallel. Please note that Include Controller is not an option since I want to use(or honor) the ThreadGroup and User Defined Variables in each jmx files.
Thanks for your help
Perhaps Parallel Ant Task is what you're looking for.
However <parallel> directive is not thread safe so I wouldn't recommend to use it with JMeter Ant task and consider using i.e. command-line mode, maven plugin or custom Java class which will spawn individual JMeter tests with it.
See 5 Ways To Launch a JMeter Test without Using the JMeter GUI guide for details of the approaches, hope this helps to find the one which matches your environment.
Yes, Ant parallel solves this problem.
I am using Ant and want to enable checkstyle for all packages,source, etc. Ideally it would have been as simple as adding a dependency on checkstyle on my existing build target but that broke the build because of violations. I don't want to do disabling using the comment style as that imply a change to the source files.
THE disabling I want to do is a specific type of check (e.g. trailing whitespace due to millions of violating lines in the existing codebase)
Is there a way to configure checkstyle to do that?
You can enable and disable checks by adding or removing them from the Checkstyle configuration file that you specify when running the Checkstyle Ant task. Checkstyle runs exactly the checks that are present in the configuration XML (e.g. the Sun Checks).
It is not possible to disable a check which is present in the configuration:
<module name="EmptyBlock">
<property name="enabled" value="false" /> <!-- won't work -->
</module>
It is also not possible to tell Checkstyle to run "all checks except EmptyBlock", because there is no such thing as "all checks" - the set of available checks depends entirely on the configuration XML. However, it may be a good addition to the Checkstyle tool to support disabling of checks like shown above, as this would make life easier for people not using a configuration GUI.
If you don't want Checkstyle violations to fail the build, set the failOnViolation parameter of the Checkstyle Ant task to false. You can also use the maxWarnings and maxErrors parameters in order to set thresholds for how many warnings or errors to tolerate before the build should break.
Which violations are counted as errors and which as warnings depends on the severity property of the individual check in the Checkstyle configuration that you specify (docs). The default severity is 'warning'.
Is there a way to change how Jenkins computes build health based on failing tests? I'd like Jenkins to treat any failing tests as something other than "sunny", but so far my searching for a way to do that has been fruitless. Does the standard setup allow this level of control, or are there perhaps plugins that can do this?
If you use the xUnit plugin, which supports several test report formats, you can add a post-build action to parse your build's test reports and declare a build as unstable or failed depending on the number of tests that fail or are skipped.
When running unit tests, Gradle can execute multiple tests in parallel without any changes to the tests themselves (i.e. special annotations, test runners, etc.). I'd like to achieve the same thing with ant, but I'm not sure how.
I've seen this question but none of the answers really appeal to me. They either involve hacks with ant-contrib, special runners set up with the #RunWith annotation, some other special annotations, etc. I'm also aware of TestNG, but I can't make the Eclipse plug-in migrate our tests - and we have around 10,000 of them so I'm not doing it by hand!
Gradle doesn't need any of this stuff, so how do I do it in ant? I guess Gradle uses a special runner, but if so, it's set up as part of the JUnit setup, and not mentioned on every single test. If that's the case, then that's fine. I just don't really want to go and modify c. 10,000 unit tests!
Gradle doesn't use a special JUnit runner in the strict sense of the word. It "simply" has a sophisticated test task that knows how to spin up multiple JVMs, run a subset of test classes in each of them (by invoking JUnit), and report back the results to the JVM that executes the build. There the results get aggregated to make it look like a single-JVM, single-threaded test execution. This even works for builds that define their own test listeners.
To get parallel test execution in Ant, you would need an Ant task that supports this feature (not sure if one exists). An alternative is to import your Ant build into Gradle (ant.importBuild "build.xml") and add a test task on the Gradle side.