4

我的专家:

            <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>

我的课:

package com.rubberduck;
public class TestState
{
    public interface Ready {
        /* to allow filter ready tests as groups */
    }    
    public interface InProgress {
        /* to allow filter ready tests as groups */
    }    
    public interface NotTested {
        /* to allow filter ready tests as groups */
    }    
}

我的测试:

@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

如果我给他<groups>com.rubberduck.TestState</groups>它编译没有错误,但我想在同一个类中为组有多个接口,这不可能吗?

4

2 回答 2

5

您可以像这样在类中指定接口:

<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>
于 2014-04-25T15:33:14.273 回答
0

Try making the interface definitions static but this begs the question, why not just define each interface in its own file? This in no way changes your ability to use them or assign multiple of them to a JUnit test.

于 2013-07-17T12:09:33.133 回答