Java Arquillian容器内测试:只有第一个测试通过,其他测试失败

Java Arquillian容器内测试:只有第一个测试通过,其他测试失败,java,jakarta-ee,junit,integration-testing,jboss-arquillian,Java,Jakarta Ee,Junit,Integration Testing,Jboss Arquillian,我编写了一些容器测试,以查看是否抛出了正确的异常。如果我分别运行测试类中的每个测试,它们就会工作,但是如果我同时运行类中的所有测试,则只有第一个测试通过,其他所有测试都会失败。错误为:java.lang.AssertionError:预期异常:de.paylax.exception.user.KYCValidationAlreadyAskedException 我从eclipse(JUnit4 Runner)运行测试 这是我的测试课: @RunWith(Arquillian.class) pub

我编写了一些容器测试,以查看是否抛出了正确的异常。如果我分别运行测试类中的每个测试,它们就会工作,但是如果我同时运行类中的所有测试,则只有第一个测试通过,其他所有测试都会失败。错误为:
java.lang.AssertionError:预期异常:de.paylax.exception.user.KYCValidationAlreadyAskedException

我从eclipse(JUnit4 Runner)运行测试

这是我的测试课:

@RunWith(Arquillian.class)
public class PaymentBoundaryExceptionTests extends InContainerTest {

    @Inject
    private PaymentBoundary paymentBoundary;

    @Inject
    private ContractControl contractControl;

    @Inject
    private UserControl userControl;
/***********************************************************************
     * Exception Tests
     */

    /**
     * Check if Exception is thrown when wrong payout amount
     */
    @Test(expected = WrongTransactionAmountException.class)
    @UsingDataSet({ "datasets/common/common.yml", "datasets/payments/payments.yml" })
    public void PaymentBoundary_WrongPayOutAmount_WrongTransactionAmountException() {
        ContractEntity contractEntity = contractControl.findContractByContractCode("goodsContract");
        paymentBoundary.createPayout(100, 20, 10, contractEntity.getPayee(), contractEntity, "test");
    }

    /**
     * Check if Exception is thrown when wrong transfer amount
     */
    @Test(expected = WrongTransactionAmountException.class)
    @UsingDataSet({ "datasets/common/common.yml", "datasets/payments/payments.yml" })
    public void PaymentBoundary_WrongTransferAmount_WrongTransactionAmountException() {
        ContractEntity contractEntity = contractControl.findContractByContractCode("goodsContract");
        paymentBoundary.transferFromWalletToWallet(contractEntity.getPayer(), contractEntity.getPayee(), 100, 20, 10,
                contractEntity);
    }
    // .... more tests here
我猜我的测试设置有问题。 这是我的失禁测试:

public abstract class InContainerTest {

    /**
     * Create the Web Archive.
     * 
     * @return the web archive
     */
    @Deployment(testable = true)
    public static final WebArchive createDeployment() {
        // loads the pom configuration
        File[] dependencies = Maven.resolver().loadPomFromFile("pom.xml").importRuntimeDependencies().resolve()
                .withTransitivity().asFile();
        // loads the mockito framework for testing
        File mockito = Maven.resolver().loadPomFromFile("pom.xml").resolve("org.mockito:mockito-all:1.10.19")
                .withTransitivity().asSingleFile();
        // adds the package for MyProject pointing to the RestMyProject api
        WebArchive war = ShrinkWrap.create(WebArchive.class).addPackages(true, "de.MyProject").addClass(RestMyProject.class)
                .addAsLibraries(dependencies).addAsLibraries(mockito)
                // adds the test perisistence xml configuration
                .addAsResource("test-persistence.xml", "META-INF/persistence.xml")
                // adds the test beans.xml and the log4j2.xml
                .addAsResource("test-beans.xml", "META-INF/beans.xml").addAsResource("log4j2.xml", "log4j2.xml")
                // adds the MyProjectMapping.xml
                .addAsResource("MyProjectMapping.xml", "MyProjectMapping.xml")
                // EMail Templates
                .addAsResource("HTMLEmailTemplate/admin-info.html", "HTMLEmailTemplate/admin-info.html")
                // SQL
                .addAsResource("datasets/scripts/truncate-users.sql", "datasets/scripts/truncate-users.sql")
                .addAsResource("datasets/scripts/autoincrement-users.sql", "datasets/scripts/autoincrement-users.sql")
                .addAsResource("datasets/scripts/contracts.sql", "datasets/scripts/contracts.sql");
        ;
        return war;
    }
}

另外,我在每次测试中使用
@UsingDataSet()
,而不是在类中使用一次,这是错误的吗?就我的理解而言,对于每个
@Test

关于可以在类级别设置的@UsingDataSet,表将以这种方式重置并设定种子。APE负责在每次测试后删除数据。您可以修改此行为,但IIRC的工作方式是这样的

快速概述我没有发现任何错误,您是否尝试过调试您的测试(您可以使用嵌入式容器使其更简单)并检查引发异常的原因?还要尝试在类级别上移动using数据集,以查看它是否与APE相关。嘿,谢谢,我已经尝试将数据集移动到类级别,但没有帮助。我试着调试测试,但不幸的是,它没有在我的断点上停止。您是否知道调试容器内测试的设置?可能您使用的是托管或远程模式,这意味着进程正在另一个JVM中运行。因此,您可以从远程调试开始,也可以使用嵌入式模式依赖项,使其与IDE在同一JVM中使用,这样您就可以像往常一样进行调试。很抱歉,回复太晚,我花了一些时间才开始远程调试。这与我的yaml数据种子文件中的错误有关。非常感谢。