gpt4 book ai didi

java - Cucable插件: How can I avoid running the '[CUCABLE:FEATURE].feature' (java template file)?

转载 作者:行者123 更新时间:2023-12-02 04:38:50 25 4
gpt4 key购买 nike

以下是我的 cucumber 模板 java 文件。

    package some.template;

import cucumber.api.CucumberOptions;
//import cucumber.api.junit.Cucumber;
import cucumber.api.testng.CucumberFeatureWrapper;
import cucumber.api.testng.PickleEventWrapper;
import cucumber.api.testng.TestNGCucumberRunner;
//import org.junit.runner.RunWith;
import org.testng.IRetryAnalyzer;
import org.testng.ITestResult;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;


//@RunWith(Cucumber.class)
@CucumberOptions(
glue = "com.fifa.stepdefs",
features = {"target/parallel/features/[CUCABLE:FEATURE].feature"},
plugin = {"json:target/cucumber-report/[CUCABLE:RUNNER].json"}
)

public class CucableJavaTemplate implements IRetryAnalyzer {

private int count = 0;
private static int maxTry = 3;

@Override
public boolean retry(ITestResult iTestResult) {
if (!iTestResult.isSuccess()) { ;//Check if test not succeed
if (count < maxTry) { //Check if maxtry count is reached
count++; //Increase the maxTry count by 1
iTestResult.setStatus(ITestResult.FAILURE); //Mark test as failed
return true; //Tells TestNG to re-run the test
} else {
iTestResult.setStatus(ITestResult.FAILURE); //If maxCount reached,test marked as failed
}
} else {
iTestResult.setStatus(ITestResult.SUCCESS); //If test passes, TestNG marks it as passed
}
return false;
}
private TestNGCucumberRunner testNGCucumberRunner;

@BeforeClass(alwaysRun = true)
public void setUpClass() throws Exception {
System.out.println("Before Scenario ****");
testNGCucumberRunner = new TestNGCucumberRunner(this.getClass());
}

@Test(groups = "cucumber", description = "Runs Cucumber Scenarios", dataProvider = "scenarios",retryAnalyzer = CucableJavaTemplate.class)
public void scenario(PickleEventWrapper pickleEvent, CucumberFeatureWrapper cucumberFeature) throws Throwable {
testNGCucumberRunner.runScenario(pickleEvent.getPickleEvent());
}

@DataProvider
public Object[][] scenarios() {
return testNGCucumberRunner.provideScenarios();
}

@AfterClass(alwaysRun = true)
public void tearDownClass() throws Exception {
System.out.println("After Scenario ****");
testNGCucumberRunner.finish();
}
}

当我运行 mvn clean verify 时,会发生以下情况:

  1. 功能文件中的场景分为多个场景,并且生成个人运行者
  2. 测试已运行。但在运行实际测试之前,cucumber-testng 还会尝试运行“[CUCABLE:FEATURE].feature”并失败并出现错误:

[Utils] [错误] [错误] java.lang.IllegalArgumentException:不是文件或目录:/projectpath/target/parallel/features/[CUCABLE:FEATURE].feature

  • 如何避免运行“[CUCABLE:FEATURE].feature”?

最佳答案

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>

我想我已经明白了这一点。添加了上述插件,现在将跳过这些测试。

关于java - Cucable插件: How can I avoid running the '[CUCABLE:FEATURE].feature' (java template file)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56531151/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com