当前位置: 代码迷 >> J2SE >> Junit的Ignore没有起作用,BeforeClass下的方法无输出解决方法
  详细解决方案

Junit的Ignore没有起作用,BeforeClass下的方法无输出解决方法

热度:286   发布时间:2016-04-24 01:41:15.0
Junit的Ignore没有起作用,BeforeClass下的方法无输出
Java code
package com.walkman.junit.test;import org.junit.AfterClass;import org.junit.Before;import org.junit.BeforeClass;import org.junit.Ignore;import org.junit.Test;import com.walkman.junit.Demo;import junit.framework.TestCase;import static org.junit.Assert.*;import static org.hamcrest.Matchers.*;public class DemoTest extends TestCase {        @BeforeClass    public static void beforeClass() {        System.out.println("beforeClass");    }        @AfterClass    public static void afterClass() {        System.out.println("afterClass");    }    @Before    public void before() {        System.out.println("before");    }        @Test    public void testAdd() {        int z = new Demo().add(3, 5);//        assertEquals(8, z);//        fail("Not yet implemented");        assertThat(z, is(8));    }    @Test    public void testDivide(){        double z = new Demo().divide(18, 6);        assertThat(z, is(3.0));    }        @Ignore    @Test(expected=java.lang.ArithmeticException.class)    public void testDivideTwo() {        double z = new Demo().divide(8, 0);    }}


出现了两个问题:
1 Ignore下的方法依然会被执行。

2 beforeClass中的outprintln语句没有输出。

用的是JUNIT4的环境。

大神们请指教。

------解决方案--------------------
JUnit4貌似没有TestCase这个类吧....
  相关解决方案