【问题标题】:Arquillian ContiPerf integrationArquillian ContiPerf 集成
【发布时间】:2012-11-15 16:39:14
【问题描述】:

我在 ContiPerf 2 上成功开发了一个玩具单元测试。 当我尝试在 Arquillian 单元测试中执行相同操作时,ContiPerf 注释 @PerfTest 似乎不起作用,而注释 @Required 运行良好。 我的测试类看起来像

@RunWith(Arquillian.class)
public class PerformanceFacadeBeanTest {

    @Rule
    public ContiPerfRule i = new ContiPerfRule();

    @EJB
    private PerformanceFacadeRemote performanceRemote;

    @Deployment
    public static Archive<EnterpriseArchive> createArchive() {
        ...
    }

    @Test
    @InSequence(value=1)
    @PerfTest(invocations = 100, threads = 5)
    @Required(max = 1200, average = 250)
    public void testPerformanceOnCacheLocal() {
    testPerformanceOnCache(performanceLocal);
    }

    private void testPerformanceOnCache(PerformanceFacade performanceFacade) {
    performanceFacade.performOnCache();
    }
}

我得到的例外是

org.databene.contiperf.PerfTestExecutionError: org.junit.internal.runners.model.MultipleFailureException: There were 2 errors:
  java.lang.NullPointerException(null)
  java.lang.NullPointerException(null)
    at org.databene.contiperf.util.ContiPerfUtil.executionError(ContiPerfUtil.java:66)
    at org.databene.contiperf.junit.JUnitInvoker.invoke(JUnitInvoker.java:54)
    at org.databene.contiperf.util.InvokerProxy.invoke(InvokerProxy.java:46)
    at org.databene.contiperf.PerformanceTracker.invoke(PerformanceTracker.java:97)
    at org.databene.contiperf.CountRunner.run(CountRunner.java:52)
    at java.lang.Thread.run(Thread.java:722)

有什么想法吗? 如果需要,我可以发布我的 pom.xml。

【问题讨论】:

    标签: jakarta-ee automated-tests performance-testing jboss-arquillian contiperf


    【解决方案1】:

    目前,您不能将 ContiPerf2 与 Arquillian 一起使用。目前,Arquillian 使用 ThreadLocal 实例进行记账,这些实例不适用于由 ContiPerf 规则生成的线程。因此,NullPointerException 因为 Arquillian 测试运行程序可能无法在除一个线程之外的所有线程中找到 ThreadLocal 实例。 Arquillian 的这种行为可能会在未来的版本中改变;但在该领域没有任何承诺。

    我现在建议使用 JUnitBenchmarks,因为据报道它可以通过自定义 Arquillian 扩展正常工作。

    【讨论】:

    猜你喜欢
    • 2015-01-17
    • 2018-01-16
    • 2012-08-22
    • 1970-01-01
    • 2011-03-29
    • 1970-01-01
    • 2014-03-18
    • 2012-01-12
    • 1970-01-01
    相关资源
    最近更新 更多