Closed praveenc79 closed 6 years ago
Hi @praveenc79,
thanks for your issue. Unfortunately, I cannot reproduce the issue. Therefore some questions:
mvn
do you use? (mvn --version
)surefire-plugin
do you use? (see pom.xml
or build log)junit-dataprovider
and spring-test
do you use? (mvn dependency:tree
)Use Maven (v3.5.2 with surefire-plugin v2.17) on branch issue111-single-dataprovider-test-mvn-cmd-line from folder junit4
with a zsh:
# works without Spring
mvn -Dtest=\*JavaAcceptanceTest#testAddWithoutDataProvider clean test
mvn -Dtest=\*JavaAcceptanceTest#testIsEmptyString clean test
mvn -Dtest=\*JavaAcceptanceTest#testIsEmptyString\* clean test
# works with Spring
mvn -Dtest=\*SpringAcceptanceTest#testCreateGreetingDataProvider clean test
mvn -Dtest=\*SpringAcceptanceTest#testCreateGreetingNoDataProvider clean test
mvn -Dtest=\*SpringAcceptanceTest#testCreateGreeting\* clean test
In comparision use Gradle (v4.6) from repoistory root
folder:
# does not work without Spring
./gradlew junit4:integTest --tests \*JavaAcceptanceTest.testIsEmptyString
# does not work with Spring
./gradlew junit4:integTest --tests \*SpringAcceptanceTest#testCreateGreetingDataProvider
# works without Spring
./gradlew junit4:integTest --tests \*JavaAcceptanceTest.testAddWithoutDataProvider
./gradlew junit4:integTest --tests \*JavaAcceptanceTest.testIsEmptyString\*
# works with Spring
./gradlew junit4:integTest --tests \*SpringAcceptanceTest#testCreateGreetingNoDataProvider
./gradlew junit4:integTest --tests \*SpringAcceptanceTest#testCreateGreeting\*
hi @aaschmid
Thanks for coming up with project and examples in that. I really appreciate that. And a big apologies to come back to you late on this as well unlike your amazingly prompt response. After cloning this project and running your example though the way I needed, I did reproduce the problem. So it might be how I need or I how I am using it. I only need to to run say one test (taking input parameter)and this is how I am trying -
mvn -Dtest=JavaAcceptanceTest#testIsEmptyString clean test
and here is output - [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 3.788 s [INFO] Finished at: 2018-05-22T12:18:48-07:00 [INFO] Final Memory: 21M/217M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.17:test (default-test) on project junit-dataprovider: No tests were executed! (Set -DfailIfNoTests=false to ignore this error.) -> [Help 1] [ERROR]
Any suggestions?
Thanks a bunch in advance, Praveen
The problem is the missing \*
before JavaAcceptanceTest
such that the command must be
mvn -Dtest=\*JavaAcceptanceTest#testIsEmptyString clean test
Otherwise you can also use the full class name:
mvn -Dtest=DataProviderJavaAcceptanceTest#testIsEmptyString clean test
Better?
You are absolutely correct @aaschmid !!! I was confused by the total number of tests being run with those. When I closely looked at the test it shows runs for various data set.
It does not work in our project though. I will continue to work on that.
I am closing issue.
Thx @praveenc79. If you have any further questions or issues, don't hesitate to open an issue.
Overview
DataProviderRunnerWithSpring does not seem to support selectively running test from a testclass.
For example, In my project I have test - call TestClass and a specific test call test 1 @RunWith(DataProviderRunnerWithSpring.class) @ContextConfiguration(classes = IntegrationTestConfiguration.class) public class TestClass {
@UseDataProvider(value = TestDataProvider.USER, location = TestDataProvider.class) @Test public void test1(String userId) { .... }
@Test public void test2() { .... } }
Now if I run test as follows (using sure-fire plugin):--
mvn -Dtest=TestClass#test1 test
It does not pickup test1
mvn -Dtest=TestClass#test2 test
will work absolutely fine
Do you have any thoughts on this? Is this a new feature request ?