2

Maven ビルドまたはインストールで、Spring プロジェクトで JUnit テストを実行しようとしています。

src/main/test のテスト クラス:

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {
        "classpath:mvc-dispatcher-servlet.xml", 
        "classpath:appContext.xml",
        "classpath:databaseContext.xml"})
    public class Test {
        @Autowired
        private EventService evtService;

        @org.junit.Test
        public void test1(){
            List<String> eventNames = evtService.getEventNames();
            Assert.assertTrue(eventNames.size() > 0);
        }
    }

POM で:

<plugin>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.7.2</version>
    <configuration>
        <parallel>classes</parallel>
        <threadCount>10</threadCount>
    </configuration>
</plugin>

Run as -> JUnit test を使用して eclipse から Test クラスを実行すると、正常に動作しますが、たとえば Maven Install を実行すると、次のようになります。

 T E S T S
-------------------------------------------------------
Concurrency config is parallel='classes', perCoreThreadCount=true, threadCount=10, useUnlimitedThreads=false
There are no tests to run.

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

バージョン: JUnit: 4.11; 春: 3.2.3.RELEASE

4

2 に答える 2

4

これが単純な問題であるよりも質問での言及が正しい場合は、代わりThe test class in src/main/testに原因テストを配置する必要があります/src/test/java

于 2013-09-15T12:49:31.357 に答える