Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Maven can';是否从具有多个接口的类中加载JUnit类别的组?_Maven_Junit_Interface_Categories - Fatal编程技术网

Maven can';是否从具有多个接口的类中加载JUnit类别的组?

Maven can';是否从具有多个接口的类中加载JUnit类别的组?,maven,junit,interface,categories,Maven,Junit,Interface,Categories,我的马文: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.15</version> &l

我的马文:

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.15</version>
                <configuration>
                    <groups>
                        com.rubberduck.TestState.Ready
                    </groups>
                </configuration>
            </plugin>
我的测试:

@Test(timeout = 60000)
@Category(TestState.Ready.class)
public void test() throws Exception {
    assertEquals(true, true);
}
我的错误:

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.14.1:test (default-cli) on project rubberduck: Execution default-cli of goal org.apache.maven.plugins:maven-surefire-plugin:2.14.1:test failed: There was an error in the forked process
java.lang.RuntimeException: Unable to load category: com.rubberduck.TestState.Ready

如果我给他
com.rubberduck.TestState
它编译时不会出错,但我想在同一个类中为组提供多个接口,这不是可能的吗?

尝试将接口定义设为静态,但这就引出了一个问题,为什么不在自己的文件中定义每个接口呢?这不会改变您使用它们或将多个它们分配给JUnit测试的能力。

您可以在类中指定如下接口:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.15</version>
    <configuration>
        <groups>
             com.rubberduck.TestState$Ready
        </groups>
    </configuration>
</plugin>

org.apache.maven.plugins
maven surefire插件
2.15
com.rubberduck.TestState$Ready

static没有区别,仍然声称“无法加载”。我有多个组,我想在一个文件中维护它们。我不太喜欢三行java类:Dsee
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.15</version>
    <configuration>
        <groups>
             com.rubberduck.TestState$Ready
        </groups>
    </configuration>
</plugin>