MushyPeas
MushyPeas

Reputation: 2507

Maven can't load groups for JUnit categories out of a class with multiple interfaces?

My Maven:

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

My Class:

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 */
    }    
}

My Test:

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

My Error:

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

If I give him <groups>com.rubberduck.TestState</groups> it compiles without error, but I want to have multiple interfaces for groups in the same class, isn't that possible?

Upvotes: 4

Views: 4170

Answers (2)

bungdonuts
bungdonuts

Reputation: 76

You can specify interfaces within classes like this:

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

Upvotes: 5

John B
John B

Reputation: 32959

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.

Upvotes: 0

Related Questions