2014-07-10 6 views
3

필자의 새로운 Play 2.3.1 Java 응용 프로그램에서는 첫 번째 테스트를 작성하지만 전혀 작동하지 않습니다. activator test을 실행하고 간단한 테스트 클래스를 기본 패키지에 직접 넣은 test 디렉토리에 도달하지 못했습니다.JUnit 테스트가 Play 2.3.1/Java 프로젝트에서 작동하지 않는 이유는 무엇입니까?

import org.junit.Assert; 
import org.junit.Test; 

public class TestTest { 

    @Test 
    public void testTest() { 
     Assert.assertEquals(true, false); 
    } 
} 

내가 activator testOnly TestTest를 실행, 나는 다음과 같은 출력이 있습니다

[info] Passed: Total 0, Failed 0, Errors 0, Passed 0 
[info] No tests to run for test:testOnly 
[success] Totaltime: 6 s, completed 11 juil. 2014 09:08:38 

어떤 원인이 될 수 있습니까?

답변

1

유용한 솔루션을 얻으려면 문제가 더 필요하므로 문제가 해결됩니다.

버전을 확인하려면 activator --version을 실행하십시오. 광산은 sbt 발사기 0.13.5를 기반으로합니다.

➜ sandbox activator --version 
sbt launcher version 0.13.5 

활성제 자체의 버전에 대해서는 많이 말하지 않습니다 (그러나 활성제 1.2.x는 가능성이 매우 높습니다 0.13.5). 당신이 나이가들 경우 업그레이드하십시오.

Ran activator new my-brand-new-play-app play-java Play/Java 응용 프로그램을 만듭니다.

➜ sandbox activator new my-brand-new-play-app play-java 

Fetching the latest list of templates... 

OK, application "my-brand-new-play-app" is being created using the "play-java" template. 

To run "my-brand-new-play-app" from the command line, "cd my-brand-new-play-app" then: 
/Users/jacek/sandbox/my-brand-new-play-app/activator run 

To run the test for "my-brand-new-play-app" from the command line, "cd my-brand-new-play-app" then: 
/Users/jacek/sandbox/my-brand-new-play-app/activator test 

To run the Activator UI for "my-brand-new-play-app" from the command line, "cd my-brand-new-play-app" then: 
/Users/jacek/sandbox/my-brand-new-play-app/activator ui 

나는 다음 변경없이 test/TestTest.javaTestTest 클래스를 복사 :

➜ my-brand-new-play-app cat test/TestTest.java 
import org.junit.Assert; 
import org.junit.Test; 

public class TestTest { 

    @Test 
    public void testTest() { 
    Assert.assertEquals(true, false); 
    } 
} 

을 유일한 변경으로 테스트 파일을 생성, 나는 activator test을 달렸다. 파일 다운로드의 전체를 많이 한 결과였다 :

➜ my-brand-new-play-app activator test 
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins 
[info] Loading project definition from /Users/jacek/sandbox/my-brand-new-play-app/project 
[info] Set current project to my-brand-new-play-app (in build file:/Users/jacek/sandbox/my-brand-new-play-app/) 
[info] ApplicationTest 
[info] + ApplicationTest.simpleCheck 
[info] + ApplicationTest.renderTemplate 
[info] 
[info] 
[info] Total for test ApplicationTest 
[info] Finished in 0.015 seconds 
[info] 2 tests, 0 failures, 0 errors 
[error] Test IntegrationTest.test failed: <''> should contain the String:<'Your new application is ready.'>, took 1.742 sec 
[info] IntegrationTest 
[info] x IntegrationTest.test 
[error] sbt.ForkMain$ForkError: <''> should contain the String:<'Your new application is ready.'> 
[error]  at org.fest.assertions.Fail.failure(Fail.java:228) 
[error]  at org.fest.assertions.Assert.failure(Assert.java:149) 
[error]  at org.fest.assertions.StringAssert.contains(StringAssert.java:73) 
[error]  at IntegrationTest$1.invoke(IntegrationTest.java:23) 
[error]  at IntegrationTest$1.invoke(IntegrationTest.java:20) 
[error]  at play.test.Helpers.running(Helpers.java:549) 
[error]  at play.test.Helpers.running(Helpers.java:536) 
[error]  at IntegrationTest.test(IntegrationTest.java:20) 
[info] 
[info] 
[info] Total for test IntegrationTest 
[info] Finished in 0.005 seconds 
[info] 1 tests, 1 failures, 0 errors 
[error] Test TestTest.testTest failed: expected:<true> but was:<false>, took 0.0 sec 
[info] TestTest 
[info] x TestTest.testTest 
[error] sbt.ForkMain$ForkError: expected:<true> but was:<false> 
[error]  at org.junit.Assert.fail(Assert.java:88) 
[error]  at org.junit.Assert.failNotEquals(Assert.java:743) 
[error]  at org.junit.Assert.assertEquals(Assert.java:118) 
[error]  at org.junit.Assert.assertEquals(Assert.java:144) 
[error]  at TestTest.testTest(TestTest.java:8) 
[info] 
[info] 
[info] Total for test TestTest 
[info] Finished in 0.002 seconds 
[info] 1 tests, 1 failures, 0 errors 
[error] Failed: Total 4, Failed 2, Errors 0, Passed 2 
[error] Failed tests: 
[error]  IntegrationTest 
[error]  TestTest 
[error] (test:test) sbt.TestsFailedException: Tests unsuccessful 
[error] Total time: 3 s, completed Jul 10, 2014 11:27:04 PM 

TestTest 테스트가 실제로 실행되었다. 모두

➜ my-brand-new-play-app activator 'testOnly TestTest' 
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins 
[info] Loading project definition from /Users/jacek/sandbox/my-brand-new-play-app/project 
[info] Set current project to my-brand-new-play-app (in build file:/Users/jacek/sandbox/my-brand-new-play-app/) 
[error] Test TestTest.testTest failed: expected:<true> but was:<false>, took 0.003 sec 
[info] TestTest 
[info] x TestTest.testTest 
[error] sbt.ForkMain$ForkError: expected:<true> but was:<false> 
[error]  at org.junit.Assert.fail(Assert.java:88) 
[error]  at org.junit.Assert.failNotEquals(Assert.java:743) 
[error]  at org.junit.Assert.assertEquals(Assert.java:118) 
[error]  at org.junit.Assert.assertEquals(Assert.java:144) 
[error]  at TestTest.testTest(TestTest.java:8) 
[info] 
[info] 
[info] Total for test TestTest 
[info] Finished in 0.012 seconds 
[info] 1 tests, 1 failures, 0 errors 
[error] Failed: Total 1, Failed 1, Errors 0, Passed 0 
[error] Failed tests: 
[error]  TestTest 
[error] (test:testOnly) sbt.TestsFailedException: Tests unsuccessful 
[error] Total time: 1 s, completed Jul 10, 2014 11:29:37 PM 

모든

, 그것은 괜찮 았는데 다음과 같이

은 또한 단지 'testOnly TestTest'으로 TestTest을 실행. 나는 당신이 문제의 설명만큼이나 당신의 단계를 따라 한 이후에 당신의 문제가 정확히 무엇인지 확신 할 수 없습니다.

+0

좋아, 내가 처음부터 내 프로젝트를 다시 시작하고 효과. 나는 나쁜 것을 한 것 같아요. –

+0

다행이었습니다. 도움이 되었다면 대답을 수락하십시오. 감사! –

5

테스트가없는 동일한 문제에 속해 있습니다. activator clean가 문제를 해결했습니다.

+0

나를 위해 일했습니다 - 고마워요. – JasonG

+1

수정되었지만 그 원인은 무엇입니까? –

0

Eclipse가 실행 중일 때 activator clean의 솔루션이 작동하지 않는 경우가 있습니다. Eclipse를 닫은 후 나중에 activator clean을 수행하면 나를 위해 일했습니다.