需要一个在Intellij Idea中使用Junit的例子

Yuv*_*l F 7 junit intellij-idea

也许这只是我,但我无法理解有关Intellij Idea中Junit测试集成的文档.我正在寻找的是一个简单的教程示例,例如:这是一个计算2 + 2的方法,这里是一个测试类,测试它是4.这是你设置的复选框.如果网上或Intellij Idea帮助中已有此类内容,请转介给我.我使用Idea 7.0.4并想使用JUnit 3.8或4.*.TIA.

Ale*_*x B 11

以下是我如何使用intellij和junit的一小部分示例

public class MathTest {  // Press Ctrl-Shift-F10 here to run all tests in class
    @Test
    public void twoPlusTwo() { // Press Ctrl-Shift-F10 here to run only twoPlusTwo test
        assertThat( 2+2, is( 4 ) );
    }

    @Test
    public void twoPlusThree() { // Press Ctrl-Shift-F10 here to run only twoPlusThree test
        assertThat( 2+3, is( 5 ) );
    }
}
Run Code Online (Sandbox Code Playgroud)

一旦运行测试,它将作为运行"配置"显示在屏幕顶部.然后,您可以点击绿色三角形重新运行测试,或使用调试三角形在启用断点的调试模式下运行.