【问题标题】:Run a single plug-in test method using tycho-surefire-plugin使用 tycho-surefire-plugin 运行单个插件测试方法
【发布时间】:2013-09-24 04:26:54
【问题描述】:

如何使用 tycho-surefire-plugin 在 Maven 中运行单个插件测试方法?

我尝试了带有# 的-Dtest 选项,但它不起作用:

mvn clean install -Dtest=MyUITest#testDummy

我有什么遗漏吗?

【问题讨论】:

    标签: unit-testing maven tycho surefire tycho-surefire-plugin


    【解决方案1】:

    您的问题已经回答here。

    但是,您可以使用 TestSuite 和 Filter 来实现您想要的,甚至更多自定义的测试选择。

    public class FilteredTests extends TestSuite {
    
    public static TestSuite suite() {
        TestSuite suite = new TestSuite();
    
        suite.addTest(new JUnit4TestAdapter(YourTestClass.class).filter(new Filter() {
    
                @Override
                public boolean shouldRun(Description description) {
                    return description.getMethodName().equals("Your_Method_name");
                }
    
                @Override
                public String describe() {
                    // TODO Auto-generated method stub
                    return null;
                }
            }));
    
        return suite;
    }
    

    }

    现在配置 tycho-surefire 插件来运行这个套件

    <configuration>
                    ...
                    <testSuite>bundle.symbolic.name.of.test.plugin</testSuite>
                    <testClass>package.of.test.suite.FilteredTests</testClass>
                    ...
    </configuration>
    

    【讨论】:

    • 链接问题中接受的解决方案是使用哈希字符 (#) 作为方法名称的分隔符。根据 Prasanth 的问题,这是行不通的。它对你有用吗?
    • 我有同样的问题,# 对我也不起作用。
    • 可以确认哈希语法不适用于tycho-surefire-plugin。我只是求助于忽略我类中的其他测试方法,或者将其移动到单独的临时类文件并使用-Dtest= 指定该类文件。令人沮丧的是,他们无法与标准的万能插件保持同等水平。
    • 确实令人沮丧:tycho-surefire 中的 ${test} 属性仅支持根据其文档的类:eclipse.org/tycho/sitedocs/tycho-surefire/tycho-surefire-plugin/…
    猜你喜欢
    • 2012-02-11
    • 1970-01-01
    • 1970-01-01
    • 2023-03-10
    • 1970-01-01
    • 2021-12-18
    • 1970-01-01
    • 2021-05-16
    • 1970-01-01
    相关资源
    最近更新 更多