1

以下の 2 つのバリアントの違いを理解したいと思います。

1:

@RunWith(Parameterized.class)
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
@ContextConfiguration(loader = SpringockitoContextLoader.class, locations = "classpath*:/spring/spring-test-core-service.xml", inheritLocations = false)
class MyMapperTest {
    private TestContextManager testContextManager; 
    public MyMapperTest() throws Exception{
       testContextManager = new TestContextManager(getClass());
       testContextManager.prepareTestInstance(this);
    }
}

2:

@RunWith(Parameterized.class)
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
@ContextConfiguration(loader = SpringockitoContextLoader.class, locations = "classpath*:/spring/spring-test-core-service.xml", inheritLocations = false)
class MyMapperTest {
    private TestContextManager testContextManager; 
    public MyMapperTest() {
       testContextManager = new TestContextManager(getClass());
       try {
           testContextManager.prepareTestInstance(this);
       } catch(Exception e) {
           Assert.fail(e.getMessage());
       }
    }
}

私のテストケースでは、コンストラクターの 2 番目のバリエーションを使用していました。テストを個別に実行すると、すべて正常に機能しました。しかし、CI ビルドで他の Test クラスと一緒に実行すると、これは失敗しました。

したがって、トラブルシューティングの後、コンストラクターを上記のバリアント 1 のように変更し、try..catch ブロックを削除しました。出来た。

しかし、この行動の背後にある理由は何ですか?

4

0 に答える 0