0

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

。该类没有给出错误,并且我遵循了网站上给出的示例。

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!");
    }
}

我得到以下堆栈跟踪:

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)

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

4

1 回答 1

0

纯娱乐。您可以在您的班级中删除“扩展 UISpecTestCase”并试一试,看看它是否有效:)

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

于 2015-06-17T11:40:56.757 回答