[英]junit4: How to call the other class static method in junit4 @before or @Test?
[英]Static method call from JUnit test without specifying class
是否可以从junit测试中调用静态方法而无需指定其类?
以下代码有效:
package lightsOut;
import static org.junit.Assert.*;
import org.junit.Test;
import lightsOut.LightsOutModel;
public class LightsOutModelTest {
@Test
public void testLightsOutModel1(){
assertTrue(LightsOutModel.checkWin()); // Note here
}
}
但是,当我从以下行中删除该类时,它显示了一个错误。
assertTrue(checkWin()); // Note here
错误是:
我是否总是需要在静态方法调用上指定类? 是否没有办法从类中导入所有方法,因为我尝试执行的方法似乎无效?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.