Junit???????С???
???????????? ???????[ 2014/8/12 10:12:00 ] ??????????????? Juint
???????????????????????????????????????в??У????????????????????????????С??Χ?????????????????????????????????????????????????????á?????????μ???????????????е???????????????д??main???????????в?????????????Junit??????????????????????????????????????????????????????????????????????????????й?Junit????????????????????MyElipse 8.5 ?????????
????1.??????project???????????properties-----Java Build Path-----Libraries---AddLibrary---Junit????Junit?????????????С?
????2.??project?н??????JDemo.java ?? Test.java??JDemo??????????????add()??Test????TestCase?????????£?
JDemo.java
package com.bx.testjunit;
public class JDemo {
int a;
int b;
int result;
public int add(int a??int b){
result = a + b;
return result;
}
}
Test.java
package com.bx.testjunit;
import junit.framework.TestCase;
import org.junit.After;
import org.junit.Before;
public class Test extends TestCase{
@Before
public void setUp() throws Exception {
System.out.println("Test :setUp");
}
@After
public void tearDown() throws Exception {
System.out.println("Test :tearDown");
}
public void test(){
JDemo a = new JDemo();
assertEquals(6??a.add(3?? 3));
}
}
????3.???У????Junit Test?????????????????Junit???????????????????bar?????????????????????????bar????????????????м???
?????????????????Junit3????????TestCase
???????濴???Junit4??????
package com.bx.service;
import org.junit.Test;
public class HelloWorld {
@Test
public void test(){
System.out.println("HelloWord :test");
}
}
????Junit4????????TestCase????????@Test?????expected?????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11