【问题标题】:maven failsafe plugin with Junit 5 - cannot run filtered groups using command line and Junit 5 @Tag带有 Junit 5 的 maven 故障安全插件 - 无法使用命令行和 Junit 5 @Tag 运行过滤组
【发布时间】:2019-04-30 07:47:41
【问题描述】:

我正在尝试使用 Junit 5 标签运行故障安全插件以进行集成测试。我的故障保护 POM.xml 看起来像:

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>${maven.failsafe.version}</version>
            <configuration>
                <systemProperties>
                    <phantomjs.binary.path>${phantomjs.binary.path}</phantomjs.binary.path>
                    <webdriver.chrome.driver>${webdriver.chrome.driver}</webdriver.chrome.driver>
                    <webdriver.ie.driver>${webdriver.ie.driver}</webdriver.ie.driver>
                    <webdriver.edge.driver>${webdriver.edge.driver}</webdriver.edge.driver>
                    <webdriver.gecko.driver>${webdriver.gecko.driver}</webdriver.gecko.driver>
                    <webdriver.opera.driver>${webdriver.opera.driver}</webdriver.opera.driver>
                    <selenium.wait.timeout>30</selenium.wait.timeout>
                </systemProperties>
                <configuration>
                    <groups>EveryDay|Today</groups>
                    <excludedGroups>integration, regression</excludedGroups>
                </configuration>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>integration-test</goal>
                        <goal>verify</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

并尝试做:

mvn -Dgroups=Today verify

它不起作用并运行整个套件。有什么想法吗?

我的测试方法如下:

@Test
@Tag("EveryDay")
@Tag("Today")
@DisplayName("Activities")
public void activitiesTest(){ // Some test code here }

还有我的测试课:

@ExtendWith({SpringExtension.class})
@ContextConfiguration(classes = { WebDriverConfig.class, LoggerConfig.class, EmailConfig.class})
@TestExecutionListeners(listeners= {ScreenshotTaker.class, DependencyInjectionTestExecutionListener.class, RunnerExtension.class})
public class BasicScenariosIT {
// Code 
}

【问题讨论】:

    标签: maven junit5 maven-failsafe-plugin


    【解决方案1】:

    其实解决方法很简单... 在我的 maven pom.xml 中,在故障安全插件中:

    <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <version>${maven.failsafe.version}</version>
                    <configuration>
    
                        <groups>${test.included.groups}</groups>
                        <excludedGroups>${test.excluded.groups}</excludedGroups>
    
                    </configuration>
                    <executions>
                        <execution>
                            <goals>
                                <goal>integration-test</goal>
                                <goal>verify</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
    

    注意参数:

    ${test.included.groups}
    ${test.excluded.groups}
    

    在我的 junit 5 测试中:

    @Test
    @Tag("EveryDay")
    @Tag("Today")
    @DisplayName("Activities")
    public void activitiesTest(){ // Some test code here }
    

    和命令:

    mvn -Dtest.included.groups=Today verify
    

    就是这样!!

    【讨论】:

      猜你喜欢
      • 2019-05-18
      • 2019-04-25
      • 2013-05-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-06
      • 1970-01-01
      • 2012-07-30
      相关资源
      最近更新 更多