How to run test cases with the spring-boot framework - java

I downloaded and successfully ran this project:
https://github.com/spring-guides/gs-accessing-data-mongodb
I noticed it has some test cases on the file:
https://github.com/spring-guides/gs-accessing-data-mongodb/blob/master/complete/src/test/java/hello/CustomerRepositoryTests.java
To run the main application from the command line, I do:
$ ./mvnw spring-boot:run
Now, I would like to know what command do I need to execute in order to run the test cases?
Thanks!

You just need to run this command to run your tests.
mvn test
https://spring.io/guides/gs/testing-web/ can give you more information about testing.

Related

Running Java/Selenium/Cucumber tests via command line

I have a test project built in Intellij IDEA 2021.1 using Selenium, Cucumber and Maven
The project runs fine from within Intellij but now I want to call the tests from the command line and only those with a specific tag. Below is the project layout
There is only 1 feature file at present and I only want to call the scenarios with the "regression" tag from the command line.
I have run command line with Visual Studio/Selenium in the past but this is my first go with Java so any advice on how to get this started would be great.
try to execute following
mvn verify -Dcucumber.options="--tags not #ignore"
Or
mvn verify -Dcucumber.options="--tags #runme"
where #runme is a tag over Scenario or Feature.
you can try this command:
mvn clean install "-Dcucumber.options=--tags #yourtagName"

Passing arguments to dependency eclipse plugins when using mvn-tycho

I am trying to write unit test cases for an eclipse plugin. Went through http://www.vogella.com/tutorials/EclipseTycho/article.html#run-the-build-with-the-tests and created a eclipse-test-plugin.
So, the test plugin (let's call is plugin-b) has a dependency on another plugin for which the test is written (plugin-a).
When I run mvn clean install, I can see that tycho-surefire is trying to run the tests and in the process is trying to launch plugin-a. However, plugin-a requires a set of VM args to start correctly. Am trying to pass the arguments like below:
mvn -Dabc.properties=bridge\bundles\com.blah.blah.blah.blah.bridge\abc.properties clean install
but they aren't going through to plugin-a.
Any help is greatly appreciated.
Finally figured this out:
mvn clean install -Dtycho.testArgLine="-Dabc.properties=../../bundles/com.blah.blah.blah.blah.bridge/abc.properties"
That'll pass the system properties to the test runtime.

How to run cucmber test from command line and in jenkins

i have created a cucumber framework using Java and Maven. i execute cukesRunner.java locally in eclipse. now i wanted to execute it command line and thru jenkins. could some one please guide me.
cd to your project direct (the one containing pom.xml) and type
mvn test
Your runner class ends in Test, right? E.g. RunCukeTest.java

Maven Cobertura and Package without running Unit Tests Twice

I am running maven like this:
mvn clean cobertura:cobertura package
I am noticing that my unit tests get run twice (thus doubling my build time). Is there a way to run cobertura AND generate the package in the same command without running tests twice?
An easy way would be to run two separate commands. In Bash it's then easy to chain them together into one line:
mvn clean cobertura:cobertura && mvn package -Dmaven.test.skip=true
The first bit:
mvn clean cobertura:cobertura
Does clean, runs the tests and generates the coverage report.
The second bit:
mvn package -Dmaven.test.skip=true
Does the packaging, but tells it not to run the tests.
The && is there so that if the first command fails, then it won't try to run the second.

Build fails when trying to compile spring roo sample heroku app

I'm trying to test out the sample app for spring/roo/heroku here https://devcenter.heroku.com/articles/spring-mvc-hibernate
When I run 'mvn package' I get this output: http://pastie.org/8263189
Not sure what I am doing wrong.
org.apache.maven.BuildFailureException: There are test failures.
From the exception It seems your test data is not correct.
If you okay with skip the test please run the below command else you need to fix the test failures.
mvn package -Dmaven.test.skip=true

Categories

Resources