如何在junit4 @Before
或@Test
中调用其他类静态方法?
我有一个关于如何在junit4 @Test
或@Before
中调用其他类方法的问题?
例如,我在static
UtilTool
方法
public static String readAllBytes(String filePath) {
String content = "";
try {
content = new String(Files.readAllBytes(Paths.get(filePath)));
} catch (IOException e) {
e.printStackTrace();
}
return content;
}
在junit4 @Before
中使用define方法:
@Before
public void setUp() {
System.out.println("setUp......");
UtilTool.readAllBytes("/tmp/test.txt")
但是当我在Junit4 readAllBytes
或UtilTool
@Before
的{{1}}方法时,我会收到以下错误消息
@Test
我该如何解决这个问题?
答案 0 :(得分:0)
我已经解决了这个问题,我犯了一个愚蠢的错误。我忘了在classpath中替换旧的jar。谢谢!