0

当我尝试测试应用程序(按照教程制作)时,出现以下错误

[info] Compiling 1 Java source to C:\Users\Xyzk\zentask\target\scala-2.10\classes...
[error] C:\Users\Xyzk\zentask\app\models\ModelsTest.java:4: error: package org.junit does not exist
[error] import org.junit.*;
[error] ^
[error] C:\Users\Xyzk\zentask\app\models\ModelsTest.java:5: error: package org.junit does not exist
[error] import static org.junit.Assert.*;
[error]                        ^
[error] C:\Users\Xyzk\zentask\app\models\ModelsTest.java:6: error: package play.test does not exist
[error] import play.test.WithApplication;
[error]                 ^
[error] C:\Users\Xyzk\zentask\app\models\ModelsTest.java:7: error: package play.test does not exist
[error] import static play.test.Helpers.*;
[error]                        ^
[error] C:\Users\Xyzk\zentask\app\models\ModelsTest.java:9: error: cannot find symbol
[error] public class ModelsTest extends WithApplication {
[error]                                 ^
[error]   symbol: class WithApplication
[error] C:\Users\Xyzk\zentask\app\models\ModelsTest.java:10: error: cannot find symbol
[error]     @Before
[error]      ^
[error]   symbol:   class Before
[error]   location: class ModelsTest
[error] C:\Users\Xyzk\zentask\app\models\ModelsTest.java:12: error: cannot find symbol
[error]         start(fakeApplication(inMemoryDatabase()));
[error]                               ^
[error]   symbol:   method inMemoryDatabase()
[error]   location: class ModelsTest
[error] 7 errors
[error] (compile:compile) javac returned nonzero exit code

怎么检测不到标准库?我的 ModelsTest.java

package models;
import models.*;
import org.junit.*;
import static org.junit.Assert.*;
import play.test.WithApplication;
import static play.test.Helpers.*;

public class ModelsTest extends WithApplication {
@Before
public void setUp() {
    start(fakeApplication(inMemoryDatabase()));
}

@Test
public void createAndRetrieveUser() {
    new User("bob@gmail.com", "Bob", "secret").save();
    User bob = User.find.where().eq("email", "bob@gmail.com").findUnique();
    assertNotNull(bob);
    assertEquals("Bob", bob.name);
}
}
4

1 回答 1

5

我在 Play 邮件列表中找到了解决方案。我想你把你ModelsTest.javaapp。你需要把它放进去test,而不是app

于 2013-11-12T20:53:18.680 回答