How to call the other class static method in junit4 @Before
or @Test
?
I have an question about how to call the other class method in junit4 @Test
or @Before
?
For example, I wrote a static
method in 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;
}
Use the define method in junit4 @Before
:
@Before
public void setUp() {
System.out.println("setUp......");
UtilTool.readAllBytes("/tmp/test.txt")
But I will get the following error messages when I call the readAllBytes
method from UtilTool
in Junit4 @Before
or @Test
java.lang.NoSuchMethodError: .....
How should I fix this issue?
I have fix this issue, I made a stupid mistake. I forgot replace the older jar in classpath. thanks!