signed

QiShunwang

“诚信为本、客户至上”

java单元测试

2021/5/14 22:39:55   来源:
package cn.it.datasource.jdbcTemplate;

import org.junit.Test;

import static org.junit.Assert.assertEquals;

/**
 * @program: basis
 * @description: emp
 * @author: xiflys
 * @create: 2021-05-14 22:30
 **/
public class Demo2 {
    // junit 单元测试
    @Test
    public void test1(){
        int i = 3/1;
        assertEquals(2,i);
    }
}

D:\java\jdk14\bin\java.exe -ea -Didea.test.cyclic.buffer.size=1048576 "-javaagent:D:\Program Files\JetBrains\IntelliJ IDEA 2020.1.2\lib\idea_rt.jar=14033:D:\Program Files\JetBrains\IntelliJ IDEA 2020.1.2\bin" -Dfile.encoding=UTF-8 -classpath "D:\Program Files\JetBrains\IntelliJ IDEA 2020.1.2\lib\idea_rt.jar;D:\Program Files\JetBrains\IntelliJ IDEA 2020.1.2\plugins\junit\lib\junit5-rt.jar;D:\Program Files\JetBrains\IntelliJ IDEA 2020.1.2\plugins\junit\lib\junit-rt.jar;E:\web\javastu\web\basis\out\production\day5;E:\web\javastu\web\day5\libs\c3p0-0.9.5.2.jar;E:\web\javastu\web\day5\libs\mchange-commons-java-0.2.12.jar;E:\web\javastu\web\day5\libs\mysql-connector-java-8.0.24.jar;E:\web\javastu\web\day5\libs\druid-1.2.6.jar;E:\web\javastu\web\day5\libs\commons-logging-1.2.jar;E:\web\javastu\web\day5\libs\spring-tx-5.0.0.RELEASE.jar;E:\web\javastu\web\day5\libs\spring-jdbc-5.0.0.RELEASE.jar;E:\web\javastu\web\day5\libs\spring-beans-5.0.0.RELEASE.jar;E:\web\javastu\web\day5\libs\spring-core-5.0.0.RELEASE.jar;C:\Users\Fly\.m2\repository\junit\junit\4.12\junit-4.12.jar;C:\Users\Fly\.m2\repository\org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jar" com.intellij.rt.junit.JUnitStarter -ideVersion5 -junit4 cn.it.datasource.jdbcTemplate.Demo2,test1

java.lang.AssertionError: 
Expected :2
Actual   :3
<Click to see difference>


	at org.junit.Assert.fail(Assert.java:88)
	at org.junit.Assert.failNotEquals(Assert.java:834)
	at org.junit.Assert.assertEquals(Assert.java:645)
	at org.junit.Assert.assertEquals(Assert.java:631)
	at cn.it.datasource.jdbcTemplate.Demo2.test1(Demo2.java:18)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:564)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:220)
	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:53)


Process finished with exit code -1