找不到Eclipse中的UISpec4J测试

时间:2015-06-17 11:21:36

标签: java eclipse user-interface testing uispec4j

我正在尝试使用UISpec4J库运行测试,但Eclipse说它无法找到它们。我尝试重新启动Eclipse,清理项目等。

该类没有错误,我已经按照website给出的示例进行了操作。

package com.health.gui;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.uispec4j.Button;
import org.uispec4j.Panel;
import org.uispec4j.UISpec4J;
import org.uispec4j.UISpecTestCase;
import org.uispec4j.Window;
import org.uispec4j.interception.WindowInterceptor;

import com.health.gui.input.xmlwizard.XmlFilePanel;

public class TestXmlFilePanel extends UISpecTestCase { 
    static {
        UISpec4J.init();
    }

    private Panel panel;

    @BeforeClass
    public void setUp() {
        panel = new Panel(new XmlFilePanel());
    }

    @Test
    public void editWithoutSelectedTest() {
        Button edit = panel.getButton("Edit selected");        
        Window popup = WindowInterceptor.run(edit.triggerClick());
        popup.titleEquals("Warning!");
    }
}

我得到以下stacktrace:

junit.framework.AssertionFailedError: No tests found in com.health.gui.TestXmlFilePanel
    at junit.framework.Assert.fail(Assert.java:57)
    at junit.framework.TestCase.fail(TestCase.java:227)
    at junit.framework.TestSuite$1.runTest(TestSuite.java:100)
    at junit.framework.TestCase.runBare(TestCase.java:141)
    at junit.framework.TestResult$1.protect(TestResult.java:122)
    at junit.framework.TestResult.runProtected(TestResult.java:142)
    at junit.framework.TestResult.run(TestResult.java:125)
    at junit.framework.TestCase.run(TestCase.java:129)
    at junit.framework.TestSuite.runTest(TestSuite.java:255)
    at junit.framework.TestSuite.run(TestSuite.java:250)
    at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:84)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

我真的不知道出了什么问题。也许你有一些建议?

1 个答案:

答案 0 :(得分:0)

只是为了好玩。您可以删除班级中的“扩展UISpecTestCase”并试一试,看看它是否有效:)

Junit 4.X应该支持注释,我没有看到你需要扩展UISpecTestCase的任何理由。