英文:
How to allow other than @Test annotation to be executed via maven-surefire-plugin. I want @BeforeClass and @AfterSuite to be picked
问题
在我的Java代码中,我有以下3个方法。当我运行pom.xml作为Maven Install时,只有@Test方法被选择。
@Parameters("year")
@Test(groups = {"smoke"})
public void newUserAuthenticationTest(String year){
System.out.println("Sniff-"+year);
}
@Parameters("year")
@BeforeClass(groups = {"smoke"})
public void beforeMe(String year){
System.out.println("Before -"+year);
}
@Parameters("year")
@AfterSuite(groups = {"smoke"})
public void afterMe(String year){
System.out.println("After -"+year);
}
在使用maven-surefire-plugin运行时,是否有一种方式可以包含除@Test之外的注解?
我希望包括@AfterSuite和@BeforeClass。
这是我的maven-surefire-plugin配置。
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<systemPropertyVariables>
<year>2020</year>
</systemPropertyVariables>
<suiteXmlFiles>
<suiteXmlFile>TestPlanLoc/FirstTestPlan.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
英文:
In my Java code , I have below 3 methods .When I ran the pom.xml Run as Maven Install ,
only the @Test method get picked .
@Parameters("year")
@Test (groups = {"smoke"})
public void newUserAuthenticationTest(String year){
System.out.println("Sniff-"+year);
}
@Parameters("year")
@BeforeClass (groups = {"smoke"})
public void beforeMe(String year){
System.out.println("Before -"+year);
}
@Parameters("year")
@AfterSuite (groups = {"smoke"})
public void afterMe(String year){
System.out.println("After -"+year);
}
Is there a way to include annotations other than @Test when running via maven-surefire-plugin?
I wish to have @AfterSuite ,@BeforeClass
Here is my maven-surefire-plugin configuration .
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<systemPropertyVariables>
<year>2020</year>
</systemPropertyVariables>
<suiteXmlFiles>
<suiteXmlFile>TestPlanLoc/FirstTestPlan.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
答案1
得分: 0
已解决:将执行环境更改为JDK,之前是JRE。
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论