Is there a way to separate long running (e.g. stress tests) out so they're not run by default in Maven 2?
We've had an ongoing need here that I can't figure out how to address using the stock Maven 2 tools and documentation.
Some of our developers have some very long running JUnit tests (usually stress tests) that under no circumstances should be run as a regular part of the build process / nightly build.
Of course we can use the surefire plugin's exclusion mechanism and just punt them from the build, but ideally we'd love something that would allow the developer to run them at will through Maven 2.
Asked by: Brad948 | Posted: 28-01-2022
Answer 1
Normally you would add a profile to your maven configuration that runs a different set of tests:
run this with mvn -Pintegrationtest install
<profile>
<id>integrationtest</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-client -Xmx896m -XX:MaxPermSize=192m</argLine>
<forkMode>once</forkMode>
<includes>
<include>**/**/*Test.java</include>
<include>**/**/*IntTest.java</include>
</includes>
<excludes>
<exclude>**/**/*SeleniumTest.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
<activation>
<property>
<name>integrationtest</name>
</property>
</activation>
</profile>
Answered by: Carlos382 | Posted: 01-03-2022
Answer 2
Adding to krosenvold's answer, to ensure no unexpected behavior, make sure you also have a default profile that is active by default that excludes the integration or stresstests you want to run in your special profile.
<profile>
<id>normal</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludes>
<exclude>**/**/*IntTest.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
You will need to create a profile like this, simply listing the surefire-plugin outside of a profile will override the profile should it be selected with:
mvn -P integrationtest clean install
Answered by: Sawyer516 | Posted: 01-03-2022
Answer 3
Use an integration test plugin such as the Super Helpful Integration Test Thingy to separate Integration Tests (long running, systemic) from Unit Test (purists say 30 seconds max for all true unit tests to run). Make two Java packages for your unit tests versus integration tests.
Then do not bind this plugin to a phase (the normal maven lifecycle) and only run it when it is explicitly called as a target, like so:
mvn shitty:clean shitty:install shitty:test
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>shitty-maven-plugin</artifactId>
</plugin>
</plugins>
This way, your normal developers will not be impacted, and you'll be able to run integration tests on demand.
Answered by: Haris471 | Posted: 01-03-2022Answer 4
Another option is to have the stress test detect it is running in maven and run only once or twice. i.e. turn into a regular functional test. This way you can check the code is still good, but not run for a long time.
Answered by: John448 | Posted: 01-03-2022Similar questions
java - Should I put my test method in a separate class? If so, how?
I am very new to Java. My assignment is to create my own method and then create a class to test it in.
My question, do I create the method separate of the class, or within the class? If it is separate of the class, how do I get the class to access my method?
(Are they saved as two separate files?)
This is what I have so far, but I am getting an error that I have to initialize KILOWATT in class DWindmill. I ...
java - In a class with two timers, do they execute in two separate threads?
In a java class I have two timers
TimerTask t1 = new TimerTask() {.. }
TimerTask t2 = new TimerTask() { ...}
Do t1 and t2 execute as two separate threads? How do you verify it?
How do I separate out query string params from POST data in a java servlet
When you get a doGet or doPost call in a servlet you can use getparameterxxx() to get either the query string or the post data in one easy place.
If the call was a GET, you get data from the url/query string.
If the call was a POST, you get the post data all parsed out for you.
Except as it turns out, if you don't put an 'action' attribute in your form call.
If you specify a fully qualified or ...
ms word - How do I use Apache POI to read a .DOC file in Java to separate images from text?
I need to read a Word .doc file from Java that has text and images. I need to recognize the images & text and separate them into 2 files.
I've recently heard about "Apache POI." How I can use Apache POI to read Word .doc files?
java - Separate DLL and native call in different plugin
I want to separate some DLLs from the associated native JNI classes.
Plugins:
In plugin A the dlls are placed and
loaded when the plugin is loaded.
In
plugin B (depend on A) the JNI
classes are placed which include the
native method calls for the DLLs in A.
At runtime i get a UnsatisfiedLinkError because the JNI class can't be found.
I try to update the classloader logic by up...
parsing - How can I separate tokens in Java when there are some null tokens
i have line in .csv file as
abc,bcc,
i have to separate it into three tokens as abc bcc and null
first i had try stringTokenizer but it will not return null token so
after that i try string.split(",") but it will not return the last null string
it will return string which has null in between but not at last
so please help me
thanks in advance.
Is "else if" one whole or two separate keywords in Java?
I happen to read the practicing material for SCJP certification, and I just tripped over a chapter of flow control et al, where they give the impression that "else if" is a keyword on its own. I have always thought that it was just a normal else, containing nothing but an if block, braces o...
java - Is it possible to separate totally the HTML/CSS layout from the GWT logic?
I'd like to allow our web developers to continue to work in pure HTML and to let developers to write GWT Java-only code to write the rest of the business logic.
Is it even possible?
Have anyone tried to work with the web developers in the GWT environment?
How do you incorporate the web developers into the GWT development process?
java - Eclipse open console apps in separate window
Is there a way to configure eclipse to open console apps in a new window rather than it's own console when you run/debug them?
I'm debugging a client/server application and I'd like to see the output of both apps at once and not have to switch between the tabs...
How can I execute a Windows batch file as a separate process from Java?
I'm writing a class in Java which will be calling a Windows batch file. When I run this class, the batch file is getting opened and getting closed. How can I make the batch file continue to run after the Java program terminates?
Still can't find your answer? Check out these amazing Java communities for help...
Java Reddit Community | Java Help Reddit Community | Dev.to Java Community | Java Discord | Java Programmers (Facebook) | Java developers (Facebook)