簡體   English   中英

TestNG-僅在定義6個或更多測試時例外

[英]TestNG - Exception only when 6 or more tests are defined

以下代碼將失敗,但前提是必須定義6個或更多測試。 就是說,不管我有什么測試。 我嘗試進行5個重復測試,所有測試均通過,然后添加另一個測試以查看下面的斷言失敗。 有人知道發生了什么嗎?

我使用Spring Data Graph運行帶有Neo4J數據庫的Spring MVC(TestNG版本5.8)。

@ContextConfiguration(locations = {"classpath:application-context-test.xml"})
public class EntityTest extends AbstractTestNGSpringContextTests {

    @Autowired
    private GraphDatabaseContext graphDatabaseContext;

    @BeforeClass
    protected void setUp() throws Exception {
        Assert.assertNotNull(graphDatabaseContext);
    }

    @Test(groups = {"functest"})
    public void testEmployeeCreation() throws Exception {
       //please note that these methods are _literally_ empty.
    }

    @Test(groups = {"functest"})
    public void test2EmployeeCreation() throws Exception {
    }
    @Test(groups = {"functest"})
    public void test3EmployeeCreation() throws Exception {
    }
    @Test(groups = {"functest"})
    public void test4EmployeeCreation() throws Exception {
    }
    @Test(groups = {"functest"})
    public void test5EmployeeCreation() throws Exception {
    }

    @Test(groups = {"functest"})
    public void test6EmployeeCreation() throws Exception {
    }
}

testNG.xml:

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Maven Tests" verbose="1" annotations="JDK">

    <parameter name="echo.timeout" value="60000"/>

    <test name="Functional and Check-in Tests">

        <groups>
            <run>
                <include name="functest"/>
                <include name="checkintest"/>
            </run>
        </groups>

        <classes>
            <class name="com.noname.entity.EntityTest"/>
        </classes>

    </test>

</suite>

測試日志:

 java.lang.AssertionError: 
Expected :true
Actual   :false

    at org.testng.Assert.fail(Assert.java:84)
    at org.testng.Assert.failNotEquals(Assert.java:438)
    at org.testng.Assert.assertTrue(Assert.java:32)
    at org.testng.Assert.assertNotNull(Assert.java:352)
    at org.testng.Assert.assertNotNull(Assert.java:342)
    at com.noname.entity.EntityTest.setUp(EntityTest.java:25)

當您遇到這樣的問題時,您首先想到的是是否正在耗盡某些資源(例如數據庫連接或打開的文件)。 檢查刪除graphDatabaseContext是否graphDatabaseContext 誠然,在查看GraphDatabaseContextAbstractTestNGSpringContextTests的api時,我沒有看到需要釋放引用的任何明顯情況,但是也許更熟悉這些類的人可以從那里獲取它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM