Junit 测试 @Test 红名问题

JAVA学习网 2018-02-08 13:49:05

准备测试,如上图,都是红名

Ctrl+1 或者鼠标放在@Test上

鼠标放在@Test上出现上面这种就可直接点击安装了

如果是下边这种

 

 Test is not an annotation type,一开始发现重新建立一个项目会解决(没发现为什么),然后发现,我把测试类的类型写成了Test 重名了,令人无语啊

接着

代码:

package com.itheima.junit;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class DemoPerson {

    Person p;

    @Before
    public void before() {
        p = new Person();
        System.out.println("qian..");
        
    }

    @Test
    public void testSay() {
        
        p.say();
    }

    @Test
    public void testRun() {
        p.run();
    }
    
    @After
    public void after() {
        System.out.println("after...");
    }
}

结果

 

阅读(766) 评论(0)