当尝试并行运行黄瓜测试时,方案/步骤未定义问题

时间:2015-01-12 10:04:54

标签: groovy gradle parallel-processing cucumber cucumber-jvm

我正在尝试同时进行黄瓜测试。

这是我的构建脚本:

import groovyx.gpars.GParsPool
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'base'
group = 'com.bj.bjetf.mobile'

sourceCompatibility = 1.5
version = '1.0'

defaultTasks 'clean','run'

ext {
    projTitle = 'IOS Tests'
    projVersion = '1.0'
}

repositories {
    mavenCentral()
}

repositories {
    maven {
        url "http://repo.bodar.com/"
    }
}

buildscript {
    repositories {
        mavenCentral()
    }



    dependencies {
        classpath "org.codehaus.gpars:gpars:1.1.0"
    }
}

dependencies {

    compile project(':ioscore')
    compile project(':baseframework')
    compile group: 'junit', name: 'junit', version: '4.11'
    compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '2.38.0'
    compile group: 'org.seleniumhq.selenium', name: 'selenium-server', version: '2.38.0'
    compile group: 'org.seleniumhq.selenium', name: 'selenium-remote-driver', version: '2.38.0'
    compile group: 'io.appium', name: 'java-client', version: '1.1.0'

    compile group: 'info.cukes', name: 'cucumber-java', version: '1.1.8'
    compile group: 'info.cukes', name: 'cucumber-junit', version: '1.1.8'
    compile group: 'info.cukes', name: 'cucumber-core', version: '1.1.8'
    compile group: 'info.cukes', name: 'cucumber-picocontainer', version: '1.1.8'
    compile group: 'net.masterthought', name: 'cucumber-reporting', version: '0.0.21'
    compile group: 'com.googlecode.totallylazy', name: 'totallylazy', version: '1049'
    compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.+'
    compile group: 'ch.qos.logback', name: 'logback-core', version: '1.0.+'
    compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.0.+'
    compile group: 'io.appium', name: 'java-client', version: '1.1.0'
}



configurations {
    cucumberRuntime {
        extendsFrom testRuntime
    }
}



def concurrentMethod(String fileName, String runner) {

    def args = ['--format', 'html:target/cucumber-html-report' + runner, '--format', 'junit:target/junit-report' + runner + '.xml' , '--format', 'json:target/cucumber' + runner + '.json', '-f', 'pretty', '--tags', '@grid', '--glue', 'com.bj.bjetf.ios.tests'].join(" ")
    def classpath = configurations.cucumberRuntime.getAsPath() + ":" + sourceSets.test.output.getAsPath() + ":" + sourceSets.main.output.getAsPath()
    def main = "cucumber.api.cli.Main"
    logger.quiet "FileName: $fileName , ThreadName: $runner"
    def process = "java -cp $classpath $main $args $fileName".execute()
    process.waitForOrKill(25000)
    logger.quiet "Process Out: ${process.text}"
}


task cucumber() {
    dependsOn assemble, compileTestJava, processTestResources
    def manifestFile1 = file("environment.txt")
    def capabilitylist1 = file("capability.txt")
    // manifestFile.write(envType)
    manifestFile1.write(envType + "&" + hubUrl)
    capabilitylist1.write(device + "&" + udid + "|" + bundleid + "*" + platformVersion + "@" + platformName + "!" + deviceName + "#" + simulator)
    def cucumberTags = [];
    if (testTags.contains('&')) {
        def tags = testTags.split("&")
        tags.each { tagId ->
            cucumberTags.add('--tags')
            cucumberTags.add(tagId)
        }
        cucumberTags.add('--tags')
        cucumberTags.add('~@pending')
        cucumberTags.add('--tags')
        cucumberTags.add('~@wip')

    } else {
        cucumberTags = ['--tags', testTags, '--tags', '~@pending', '--tags', '~@wip']
    }
    logger.quiet("Tags are" + cucumberTags)
    def cucumberArgs = ['--format', 'html:target/cucumber-html-report', '--format', 'junit:target/junit-report.xml', '--format', 'json:target/cucumber.json', '-f', 'pretty', '--glue', 'com.bj.bjetf.ios.tests','src/test/resources/features'] + cucumberTags
    logger.quiet("Arguments are" + cucumberArgs)
    doLast {
        javaexec {
            jvmArgs = []
            main = "cucumber.api.cli.Main"
            classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
            args = cucumberArgs
        }
    }

}

task concurrentCucumber() {
    dependsOn assemble, compileTestJava, processTestResources
    def cores = Runtime.runtime.availableProcessors()
    def threads = 2
    def runner = "0"
    println "    > Using $threads threads on $cores cores..."
    GParsPool.withPool(threads) {
        def features = fileTree(dir: 'src/test/resources/features').include '**/*.feature'
        features.eachParallel { File file ->
            logger.quiet "File: ${file.name}"
            concurrentMethod(file.path, runner)
            runner = runner + 1;
        }
    }
    logger.quiet("Run complete!")


}


task wrapper(type: Wrapper) {
    jarFile = 'wrapper/gradle-wrapper.jar'
    gradleVersion = "1.8"
}

当我运行concurrentCucumber时,脚本会遍历所有功能文件,并查找标记为@grid的方案。

我们可以从中看到:

-----------------------------------
   _____               _ _          
  / ____|             | | |         
 | |  __ _ __ __ _  __| | | ___     
 | | |_ | '__/ _` |/ _` | |/ _ \    
 | |__| | | | (_| | (_| | |  __/    
  \_____|_|  \__,_|\__,_|_|\___|    

-----------------------------------
Tags are[--tags, @grid, --tags, ~@pending, --tags, ~@wip]
Arguments are[--format, html:target/cucumber-html-report, --format, junit:target/junit-report.xml, --format, json:target/cucumber.json, -f, pretty, --glue, com.bj.bjetf.android.tests, src/test/resources, --tags, @grid, --tags, ~@pending, --tags, ~@wip]
Tags are[--tags, @grid, --tags, ~@pending, --tags, ~@wip]
Arguments are[--format, html:target/cucumber-html-report, --format, junit:target/junit-report.xml, --format, json:target/cucumber.json, -f, pretty, --glue, com.bj.bjetf.ios.tests, src/test/resources/features/AcidScenarios, --tags, @grid, --tags, ~@pending, --tags, ~@wip]
    > Using 2 threads on 8 cores...
File: Audio only mode UI.feature
File: joinMeeting.feature
FileName: /Users/sandeep/MobileRepoAgain/bjetfmobile/iostests/src/test/resources/features/joinMeeting.feature , ThreadName: 0
FileName: /Users/sandeep/MobileRepoAgain/bjetfmobile/iostests/src/test/resources/features/Audio only mode UI.feature , ThreadName: 0
Process Out: 
File: Box document sharing.feature
FileName: /Users/sandeep/MobileRepoAgain/bjetfmobile/iostests/src/test/resources/features/Box document sharing.feature , ThreadName: 01
Process Out: None of the features at [/Users/sandeep/MobileRepoAgain/bjetfmobile/iostests/src/test/resources/features/joinMeeting.feature] matched the filters: [@grid]

0 Scenarios
0 Steps
0m0.000s


File: leaveMeeting.feature
FileName: /Users/sandeep/MobileRepoAgain/bjetfmobile/iostests/src/test/resources/features/leaveMeeting.feature , ThreadName: 011
Process Out: 
File: chat.feature
FileName: /Users/sandeep/MobileRepoAgain/bjetfmobile/iostests/src/test/resources/features/chat.feature , ThreadName: 0111
Process Out: None of the features at [/Users/sandeep/MobileRepoAgain/bjetfmobile/iostests/src/test/resources/features/leaveMeeting.feature] matched the filters: [@grid]

0 Scenarios
0 Steps
0m0.000s


File: login.feature
FileName: /Users/sandeep/MobileRepoAgain/bjetfmobile/iostests/src/test/resources/features/login.feature , ThreadName: 01111
Process Out: None of the features at [/Users/sandeep/MobileRepoAgain/bjetfmobile/iostests/src/test/resources/features/chat.feature] matched the filters: [@grid]

0 Scenarios
0 Steps
0m0.000s


File: crossPartition.feature
FileName: /Users/sandeep/MobileRepoAgain/bjetfmobile/iostests/src/test/resources/features/crossPartition.feature , ThreadName: 011111
Process Out: Feature: Normal Login Scenarios

  @mobile @Sanity_14 @Sanity_30 @grid
  Scenario: verify login with given credentials # /Users/sandeep/MobileRepoAgain/bjetfmobile/iostests/src/test/resources/features/login.feature:5
    Given I login with default credentials
    Then I should see schedule meeting option

  @mobile @Login2 @grid
  Scenario: verify login with given credentials # /Users/sandeep/MobileRepoAgain/bjetfmobile/iostests/src/test/resources/features/login.feature:11
    Given I login with default credentials
    Then I should see schedule meeting option

2 Scenarios (2 undefined)
4 Steps (4 undefined)
0m0.000s


You can implement missing steps with the snippets below:

@Given("^I login with default credentials$")
public void i_login_with_default_credentials() throws Throwable {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
}

@Then("^I should see schedule meeting option$")
public void i_should_see_schedule_meeting_option() throws Throwable {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
}


File: Logout.feature
FileName: /Users/sandeep/MobileRepoAgain/bjetfmobile/iostests/src/test/resources/features/Logout.feature , ThreadName: 0111111
Process Out: None of the features at [/Users/sandeep/MobileRepoAgain/bjetfmobile/iostests/src/test/resources/features/crossPartition.feature] matched the filters: [@grid]

0 Scenarios
0 Steps
0m0.000s


File: documentsharing.feature
FileName: /Users/sandeep/MobileRepoAgain/bjetfmobile/iostests/src/test/resources/features/documentsharing.feature , ThreadName: 01111111
Process Out: None of the features at [/Users/sandeep/MobileRepoAgain/bjetfmobile/iostests/src/test/resources/features/documentsharing.feature] matched the filters: [@grid]

0 Scenarios
0 Steps
0m0.000s


File: DoubleTaptoCancel.feature
FileName: /Users/sandeep/MobileRepoAgain/bjetfmobile/iostests/src/test/resources/features/DoubleTaptoCancel.feature , ThreadName: 011111111
Process Out: None of the features at [/Users/sandeep/MobileRepoAgain/bjetfmobile/iostests/src/test/resources/features/Logout.feature] matched the filters: [@grid]

0 Scenarios
0 Steps
0m0.000s


File: MultiEndPointMeeting.feature
FileName: /Users/sandeep/MobileRepoAgain/bjetfmobile/iostests/src/test/resources/features/MultiEndPointMeeting.feature , ThreadName: 0111111111
Process Out: None of the features at [/Users/sandeep/MobileRepoAgain/bjetfmobile/iostests/src/test/resources/features/DoubleTaptoCancel.feature] matched the filters: [@grid]

0 Scenarios
0 Steps
0m0.000s


File: ForceModLogin.feature
FileName: /Users/sandeep/MobileRepoAgain/bjetfmobile/iostests/src/test/resources/features/ForceModLogin.feature , ThreadName: 01111111111
Process Out: None of the features at [/Users/sandeep/MobileRepoAgain/bjetfmobile/iostests/src/test/resources/features/MultiEndPointMeeting.feature] matched the filters: [@grid]

0 Scenarios
0 Steps
0m0.000s


File: muteOnEntry.feature
FileName: /Users/sandeep/MobileRepoAgain/bjetfmobile/iostests/src/test/resources/features/muteOnEntry.feature , ThreadName: 011111111111
Process Out: None of the features at [/Users/sandeep/MobileRepoAgain/bjetfmobile/iostests/src/test/resources/features/muteOnEntry.feature] matched the filters: [@grid]

0 Scenarios
0 Steps
0m0.000s


File: scheduling.feature
FileName: /Users/sandeep/MobileRepoAgain/bjetfmobile/iostests/src/test/resources/features/scheduling.feature , ThreadName: 0111111111111
Process Out: None of the features at [/Users/sandeep/MobileRepoAgain/bjetfmobile/iostests/src/test/resources/features/ForceModLogin.feature] matched the filters: [@grid]

0 Scenarios
0 Steps
0m0.000s


File: Help button.feature
FileName: /Users/sandeep/MobileRepoAgain/bjetfmobile/iostests/src/test/resources/features/Help button.feature , ThreadName: 01111111111111
Process Out: 
File: inMeeting.feature
FileName: /Users/sandeep/MobileRepoAgain/bjetfmobile/iostests/src/test/resources/features/inMeeting.feature , ThreadName: 011111111111111
Process Out: None of the features at [/Users/sandeep/MobileRepoAgain/bjetfmobile/iostests/src/test/resources/features/scheduling.feature] matched the filters: [@grid]

0 Scenarios
0 Steps
0m0.000s


File: settings.feature
FileName: /Users/sandeep/MobileRepoAgain/bjetfmobile/iostests/src/test/resources/features/settings.feature , ThreadName: 0111111111111111
Process Out: None of the features at [/Users/sandeep/MobileRepoAgain/bjetfmobile/iostests/src/test/resources/features/inMeeting.feature] matched the filters: [@grid]

0 Scenarios
0 Steps
0m0.000s


File: InMeetingAudioVideo.feature
FileName: /Users/sandeep/MobileRepoAgain/bjetfmobile/iostests/src/test/resources/features/InMeetingAudioVideo.feature , ThreadName: 01111111111111111
Process Out: Feature: Settings

  @mobile @Sanity_32 @sanity @grid
  Scenario: I turn ON 'Start audio muted' in the App settings and start the meeting # /Users/sandeep/MobileRepoAgain/bjetfmobile/iostests/src/test/resources/features/settings.feature:9
    Given I login with default credentials
    And I turn "ON" 'Start audio muted' in the App settings
    And I start the personal meeting
    Then I should join the meeting with Audio muted

1 Scenarios (1 undefined)
4 Steps (4 undefined)
0m0.000s


You can implement missing steps with the snippets below:

@Given("^I login with default credentials$")
public void i_login_with_default_credentials() throws Throwable {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
}

@Given("^I turn \"(.*?)\" 'Start audio muted' in the App settings$")
public void i_turn_Start_audio_muted_in_the_App_settings(String arg1) throws Throwable {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
}

@Given("^I start the personal meeting$")
public void i_start_the_personal_meeting() throws Throwable {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
}

@Then("^I should join the meeting with Audio muted$")
public void i_should_join_the_meeting_with_Audio_muted() throws Throwable {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
}


File: signUp.feature
FileName: /Users/sandeep/MobileRepoAgain/bjetfmobile/iostests/src/test/resources/features/signUp.feature , ThreadName: 011111111111111111
Process Out: None of the features at [/Users/sandeep/MobileRepoAgain/bjetfmobile/iostests/src/test/resources/features/InMeetingAudioVideo.feature] matched the filters: [@grid]

0 Scenarios
0 Steps
0m0.000s


File: inMeetingStageLeft.feature
FileName: /Users/sandeep/MobileRepoAgain/bjetfmobile/iostests/src/test/resources/features/inMeetingStageLeft.feature , ThreadName: 0111111111111111111
Process Out: None of the features at [/Users/sandeep/MobileRepoAgain/bjetfmobile/iostests/src/test/resources/features/signUp.feature] matched the filters: [@grid]

0 Scenarios
0 Steps
0m0.000s


File: ssologin.feature
FileName: /Users/sandeep/MobileRepoAgain/bjetfmobile/iostests/src/test/resources/features/ssologin.feature , ThreadName: 01111111111111111111
Process Out: None of the features at [/Users/sandeep/MobileRepoAgain/bjetfmobile/iostests/src/test/resources/features/inMeetingStageLeft.feature] matched the filters: [@grid]

0 Scenarios
0 Steps
0m0.000s


File: inviteOnFly.feature
FileName: /Users/sandeep/MobileRepoAgain/bjetfmobile/iostests/src/test/resources/features/inviteOnFly.feature , ThreadName: 011111111111111111111
Process Out: None of the features at [/Users/sandeep/MobileRepoAgain/bjetfmobile/iostests/src/test/resources/features/ssologin.feature] matched the filters: [@grid]

0 Scenarios
0 Steps
0m0.000s


File: startMeeting.feature
FileName: /Users/sandeep/MobileRepoAgain/bjetfmobile/iostests/src/test/resources/features/startMeeting.feature , ThreadName: 0111111111111111111111
Process Out: None of the features at [/Users/sandeep/MobileRepoAgain/bjetfmobile/iostests/src/test/resources/features/inviteOnFly.feature] matched the filters: [@grid]

0 Scenarios
0 Steps
0m0.000s


Process Out: None of the features at [/Users/sandeep/MobileRepoAgain/bjetfmobile/iostests/src/test/resources/features/startMeeting.feature] matched the filters: [@grid]

0 Scenarios
0 Steps
0m0.000s


File: testdata.feature
FileName: /Users/sandeep/MobileRepoAgain/bjetfmobile/iostests/src/test/resources/features/testdata.feature , ThreadName: 011111111111111111111111
Process Out: None of the features at [/Users/sandeep/MobileRepoAgain/bjetfmobile/iostests/src/test/resources/features/testdata.feature] matched the filters: [@grid]

0 Scenarios
0 Steps
0m0.000s


Run complete!
:baseframework:compileJava UP-TO-DATE
:baseframework:processResources UP-TO-DATE
:baseframework:classes UP-TO-DATE
:baseframework:jar UP-TO-DATE
:ioscore:compileJava UP-TO-DATE
:ioscore:processResources UP-TO-DATE
:ioscore:classes UP-TO-DATE
:ioscore:jar UP-TO-DATE
:iostests:compileJava UP-TO-DATE
:iostests:processResources UP-TO-DATE
:iostests:classes UP-TO-DATE
:iostests:jar
:iostests:assemble
:iostests:compileTestJava
warning: [options] bootstrap class path not set in conjunction with -source 1.5
Note: /Users/sandeep/MobileRepoAgain/bjetfmobile/iostests/src/test/java/com/bj/bjetf/ios/tests/runners/RunCukesTests.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 warning
:iostests:processTestResources
:iostests:concurrentCucumber

BUILD SUCCESSFUL

它找到带有标记@grid的场景但是测试没有运行,因为它无法找到相同的步骤定义(未定义的场景/步骤警告),尽管--glue设置为正确的包具有步骤定义。

目前我们已经陷入困境,对此表示感谢。

提前致谢!

0 个答案:

没有答案