有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java JUnit测试错误未找到测试

我使用JUnit3,当我编写这段代码时,我遇到了这个错误

AssertionFailedError : No test Found

import junit.framework.TestCase;
import junit.runner.*;

public class Teststd extends TestCase {
    Student s;

    public void setUp() {
        s = new Student("ASJFA");
    }

    public void TestEmail() {
        try {
            s.setEmail("KUKU");
            assertTrue(false);
        } catch (EmailIsInvalid ex) {
            assertTrue(true);
            System.out.println("Exception caught. Email is invalid");

        }
    }

    public void tearDown() {
    }
}

共 (1) 个答案

  1. # 1 楼答案

    您的测试方法应该以小写的t开头。它应该是public void testEmail()。然后它将被JUnit拾取