lundi 29 février 2016

java.lang.Exception: No runnable methods (Junit)

I am using Junit 4.11 and intellij. I have two test classes that I want to run them through suite, however I get the no runnable methods exception.

Here are the test classes:

public class TrackingServiceTest {

    private TrackingService service;

    @Before
    public void setUp(){
        service = new TrackingService();
    }

    @Test
    public void NewTrackingServiceTotalIsZero() {
        assertEquals("tracking service total was not zero", 0, service.getTotal());
    }

    @Test
    public void WhenAddingProteinTotalIncreasesByThatAmount(){
        service.addProtein(10);
        assertEquals("protein amount was not correct", 10, service.getTotal());
    }

    @Test
    public void WhenRemovingProteinTotalRemainsZero(){
        service.removeProtein(5);
        assertEquals("Total suppose to be zero after removing protein",0, service.getTotal());
    }
    @Test (expected = InvalidGoalException.class)
    public void WhenGoalIsSetToLessThanZeroExceptionIsThrown() throws InvalidGoalException {
        service.setGoal(-5);
    }

    @Test (timeout = 100)
    @Ignore
    public void BadTest(){
        for(int i=0; i<100000000; i++)
            service.addProtein(i);
    }
}

And here is another sample test class just to check suite:

public class HelloJUnitTest {

    private TrackingService service;

    @Before
    public void setUp(){
        service = new TrackingService();
    }

    @Test
    public void NewTrackingServiceTotalIsZero() {
        assertEquals("tracking service total was not zero", 0, service.getTotal());
    }
}

And this is my suite class:

@RunWith(Suite.class)
@Suite.SuiteClasses(value = {
        TrackingService.class,
        HelloJUnitTest.class
})
public class ProteinTrackerSuite {

}

Aucun commentaire:

Enregistrer un commentaire