java Android重建项目,包组织。junit不存在错误
Error:(3, 17) error: package org.junit does not exist
Error:(5, 24) error: package org.junit does not exist
Error:(11, 6) error: cannot find symbol class Test
Error:(13, 9) error: cannot find symbol method assertEquals(int,int)
:app:compileDebugUnitTestJavaWithJavac FAILED
Error:Execution failed for task ':app:compileDebugUnitTestJavaWithJavac'
Compilation failed; see the compiler error output for details.
当我运行重建时,错误就是这些。但我可以运行我的应用程序而无需重建
我不使用test,我不知道它是如何出现在我的文件夹中的
代码是:
import org.junit.Test;
import static org.junit.Assert.*;
/**
* To work on unit tests, switch the Test Artifact in the Build Variants view.
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
}
# 1 楼答案
将此添加到您的构建中。格拉德尔