Running “pure” JUnit 4 tests using ant

后端 未结 9 757
一个人的身影
一个人的身影 2020-12-25 13:05

We have migrated to both JUnit 4 and ant 1.7

The tests runs fine in eclipse, but the annotations are ignored when running the tests using ant.

According to t

9条回答
  •  甜味超标
    2020-12-25 13:33

    This happened to me and it was because I was both using annotations and extending TestCase.

    public class TestXXX extends TestCase {
    
        @Test
        public void testSimpleValidCase() {
            // this was running
        }
    
        @Test
        public void simpleValidCase() {
            // this wasn't running
        }
    }
    

    When you extend TestCase you are assuming JUnit3 style so JUnit4 annotations are ignored.

    The solution is to stop extending TestCase.

提交回复
热议问题