Play Framework (2.1.3) 不运行任何测试 [英] Play Framework (2.1.3) doesn't run any tests
问题描述
我有 4 个测试类,每个类平均有两个测试函数.第一个测试如下,必须正确(来自 Play 的教程).
I have 4 test classes with an average of two test functions each. The first test is below and must be correct (its from Play's tutorial).
public class ApplicationTest {
@Test
public void simpleCheck() {
int a = 1 + 1;
assertThat(a).isEqualTo(2);
}
}
其他的都是定制的并且有一个@Before
设置,像这样:
The other ones are custom made and have a @Before
setup, like this:
public class UserTest extends WithApplication {
@Before
public void setUp() {
start(fakeApplication(inMemoryDatabase()));
}
// creation and retrieval of user
@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); // successfully retrieved
assertEquals("Bob", bob.getName()); // correct user retrieved
}
}
现在当我运行 play test
时,它完成得更快并且不执行任何测试.
Now when I run play test
it finishes a lot quicker and doesn't execute any test.
PS C:wampwwwdcid> play test
[info] Loading project definition from C:wampwwwdcidproject
[info] Set current project to dcid (in build file:/C:/wamp/www/dcid/)
[info] Compiling 4 Java sources to C:wampwwwdcid argetscala-2.10 est-classes...
[info] ApplicationTest
[info]
[info]
[info] Total for test ApplicationTest
[info] Finished in 0.014 seconds
[info] 0 tests, 0 failures, 0 errors
[info] models.UserTest
[info]
[info]
[info] Total for test models.UserTest
[info] Finished in 0.002 seconds
[info] 0 tests, 0 failures, 0 errors
[info] models.ProposalTest
[info]
[info]
[info] Total for test models.ProposalTest
[info] Finished in 0.002 seconds
[info] 0 tests, 0 failures, 0 errors
[info] Passed: : Total 0, Failed 0, Errors 0, Passed 0, Skipped 0
[success] Total time: 5 s, completed 16/Ago/2013 14:52:35
这是为什么?我能做什么?我最近从播放 2.1.2 更新到 2.1.3.我更新了所有参考资料,项目运行良好,除了测试.我也看了这个问题,但不可能是这样,因为我没有改变我的测试,所以它们写得很好,只是它们的执行不起作用.
Why is this? What can I do? I recently updated from play 2.1.2 to 2.1.3. I updated all references and the project is working fine, except the tests. I also looked at this question, but it can't be that, since I didn't change my tests, so they are well written, it's just their execution that is not working.
推荐答案
这是一个已知问题播放 2.1.3.同时,还有解决方法.将以下内容添加到 val main 函数中的 Build.scala 文件中:
It's a known issue of Play 2.1.3. Meanwhile there is a workaround. Add the following into Build.scala file in the val main function:
val main = play.Project(appName, appVersion, appDependencies).settings(
// Add your own project settings here
testOptions in Test ~= { args =>
for {
arg <- args
val ta: Tests.Argument = arg.asInstanceOf[Tests.Argument]
val newArg = if(ta.framework == Some(TestFrameworks.JUnit)) ta.copy(args = List.empty[String]) else ta
} yield newArg
}
)
这篇关于Play Framework (2.1.3) 不运行任何测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!