Skip test command on maven build is not working - java

I'm trying to build a maven project and skipping the test cases by running the command below:
mvn clean install -DSkipTests
However, I keep getting an error that I have test failures. From my understanding, it means that the build is still running the tests which I am trying to avoid for now. I have taken to consideration this existing question but I'm unsure if this is related to my case:
Maven package/install without test (skip tests)
Nonetheless, I did try the solution provided in this question. It did build my project but again, I am unsure if it did built the project the way I wanted to since package and install are different commands of maven.
Also, I did try to build it without the skip tests but I still got the same result errors.
Kindly correct me if I'm doing anything wrong. Any information will be greatly appreciated.

Related

How to skip tests when debugging test with Intellij which installs the package before debugging

I have a maven project where I'd like to debug tests using IntelliJ. The problem is that when I select the test I'd like to debug IntelliJ first executes mvn install command in order to be able to execute tests against the most recent code, and after this executes the test and allow me to debug.
I have multiple problems with this:
the project contains hundreds of tests which takes 2-3 minutes to execute them. It is super slow especially when I need to restart debugging frequently
if my test compiles, but still fails I can't start debugging since it will fail the maven install part of the execution and IntelliJ doesn't kick off debugging
I haven't found any hints in IntelliJ's doc about how to manipulate the mvn install part of the debugging process
yes, I could start maven in debug mode in the command line and attach IntelliJ to it, but that process is very fragile and it is 2021... let me use the IntelliJ fully...
I tried to add a Before launch step like mvn clean install -Dmaven.test.skip=true, but it results that the test classes won't be compiled.
My question is how can I manipulate the whole Debugging process is IntelliJ, especially the maven install part? What is the good solution here?
I'm using TestNG and the user interface doesn't offer me any option to do manipulate mvn install part.

How to make a plugin goal run regardless of test failures

I have a plugin that is supposed to send files to a database regardless of test failures. I tried setting the fail-at-end setting but the plugin still didn't run. ignoring failures altogether doesn't seem to be an option for me in this case because then faulty jars would be deployed to the artifact repository. I can use this plugin for as a separate command line script but it would be optimal if it could be put in the pom.
The tests need to be run before the plugin does, because the plugin gets the test report files.
I am aware that there are similar questions to this that have been asked before, but they don't seem to help me so I was wondering if someone has similar advice.
If the plugin has to run after the tests, the tests just can't fail the build.
Maven Surefire plugin has an option: maven.test.failure.ignore to run the tests but keep execution
See Here a full description of Test MOJO.
This should be the first bet.
Another option is to build just like this, but run the plugin "externally" (a kind of two steps build). Run maven install or whatever you need, and then (separately)
mvn <group>:<artifact>:<version>:<mojo of your plugin>
try mvn your-goal -DskipTests - will ignore testing.

Jenkins: Build and Run Maven Project

I am currently thinking about the potential solutions for building and running a Jenkins Maven project. I am a Jenkins Noob and what I currently think of is providing a Maven Plugin that runs the project right after the build and test phase. This feels wrong... .
So my basic question is, is it possible in Jenkins to configure a process to build a maven project and execute it right away and taking care for not interfering with it by starting another process and rebuilding it since a change arrived.
If this is possible it would ease the task by omitting the "Let's write a Maven plugin".
What do you means by 'execute'? Your program is a jar? If you do have to deploy it, there is tools in Jenkins to deploy with the build phase. If not, I think you can always make a 'Post build' command like java -jar nameofprogram.jar
In Jenkins you can configure jobs to execute multiple Maven targets when the jobs are run. I don't know if this answers your question, but you should be able to accomplish what you want by using "post build steps" and trigger certain behaviour from there.

Best way to run J-Meter test's from jenkins

What I want to achieve is as:
Build the maven project and push the jar to repo, using maven & jenkins.
Deploy the application, using script.
Run jmeter test cases and display test results in jenkins dashboard.
First jenkins build my project and push it to repo.
Then I have defined a post build step in jenkins to run script on remote server, this script deploys and starts my application.
Then I have created a post build action in jenkins to invoke top-level maven targets, to run mvn verify, which triggers the jmeter-maven plugin, which runs the test cases on my already running application.
Is this a good approach and if not please let me know a better way to do this?
Thanks in advance.
The bit that may be missing here is how Jenkins knows if the build should be marked as passed or failed? Even if jmeter-maven-analysis plugin execution did exit with zero exit code, it doesn't mean performance-wise the application is fine. It may be, but don't have to be. I came across that kind of concerns some time ago and provided a solution. Check project wiki for usage example and more information.

How to do a deployment pipeline with Maven

We want to accelerate our build pipeline for a multi-module Java web application, which roughly consists of
compile/code analysis
unit tests
integration tests
GUI tests
At the moment each of these build steps starts from scratch, compiling and building again and again, which costs time and means that we do not deploy the actual files to production that have gone through the tests. Is it possible to get Maven to not recompile everything on subsequent steps but instead run the tests against the previously compiled classes?
We are using Maven3 to manage our dependencies and Teamcity as a build server (7 at the moment, planning to upgrade to 8 soon). I have tried to set up a build chain, doing a
mvn clean install
on the first step and then exporting all the */target/ folders to the following builds. Then ideally I would only do a
mvn test
mvn integration-test
Unfortunately I have not been able to persuade Maven to do this properly. Either it compiles the classes again or produces errors.
Has anyone successfully done this kind of setup and has any pointers for me? Is this possible with Maven and is this even the right way to do things?

Categories