Junit: How to skip a test case in Junit ?

来源:互联网 发布:网络招人的技巧 编辑:程序博客网 时间:2024/05/29 21:33

If you using JUnit 4.x, you

If you using JUnit 4.x, you can follow this way

@Ignore // add this annotation to ignore following method@Testpublic void methodUnderTest()

Change name of testmethod or remove annotation

Be aware that failing tests are indicators for you, that something goes wrong that you have to fix. So its a bad idea to remove or deactivate testcases or methods. Instead fix the problem or change the requirements your testcase holds.

For your convenience:
If you use junit 3.x simply rename the testmethod or prefix it with "failing", for example

public void failingtestCalculateResult() {...}

So you can simply search after "failingtest" over your complete project to find all this deactivated testmethods.

If you use junit 4.x simply remove the @Test anotation at the testmethod.

If you want to skip a whole testcase simple rename it in the same way. For example.
MyRepositoryTest to MyRepositoryFailing.