Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
541 views
in Technique[技术] by (71.8m points)

testing - run single integration test with gradle

I'm trying to run a single integration tests using gradle's -Dtest.single flag. I have added another source set, src/integrationTest and put the tests in there. I have an integration test task

task integrationTests(type: Test) {
    dependsOn 'assemble', 'integrationTestClasses'    
    testClassesDir = sourceSets.integrationTest.output.classesDir
    classpath = sourceSets.integrationTest.runtimeClasspath
}

This runs fine, but if I try to run a single test it tells me it cannot find a matching test. I don't want to have to run every integration test each time I am writing a new one. Is there a way to do this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Since Gradle 1.10 you can write:

 //select specific test method
gradle test --tests org.gradle.SomeTest.someFeature

//select specific test class
gradle test --tests org.gradle.SomeTest

//select all tests from package
gradle test --tests org.gradle.internal*

//select all ui test methods from integration tests by naming convention
gradle test --tests *IntegTest*ui*

//selecting tests from different test tasks
gradle test --tests *UiTest integTest --tests *WebTest*ui

Read more here http://www.gradle.org/docs/1.10/release-notes#executing-specific-tests-from-the-command-line


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...