我如何使用JUnit进行测试? [关闭]

问题描述 投票:-1回答:1
public class MyException extends Exception{

    public MyException(String message) {

        super(message);

    }

}

只是此构造函数的简单统一测试谢谢

spring unit-testing testing junit superclass
1个回答
0
投票

尝试一下

@RunWith(JUnit4.class)
public class MyTest {

    @Test
    public void testConstructor() {

        String expected = "Testing the Constructor";
        MyException exception = new MyException(expected);

        assertEquals(expected, exception.getMessage());
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.