51Testing软件测试论坛
标题:
JUnit初级应用全介绍
[打印本页]
作者:
欺负人
时间:
2009-11-22 18:20
标题:
JUnit初级应用全介绍
package Com.TestSample;
import org.junit.After;
import org.junit.Before;
import junit.framework.TestCase;
import Com.HelloWorld.*;
public class TestSample extends TestCase {
@Before
public void setUp() throws Exception {
}
@After
public void tearDown() throws Exception {
}
public void
test
SayWorld()
{
HelloWorld obj=new HelloWorld();
assertEquals("HelloWorld", obj.sayWorld());
}
public void
test
SayChina()
{
HelloWorld obj=new HelloWorld();
assertEquals("China",obj.sayChina());
}
public void testAssertTrur()
{
HelloWorld obj=new HelloWorld();
assertNotSame("ok", "asdasdasd", obj.sayChina());
}
public static void main()
{
junit.textui.TestRunner.run(TestSample.class);
}
}
###################################################################################################
package Com.HelloWorld;
public class HelloWorld {
public String sayWorld()
{
return ("HelloWorld");
}
public String sayChina()
{
return ("China");
}
}
作者:
mentgmery
时间:
2009-11-23 10:32
呵呵
作者:
angela_51
时间:
2009-11-23 10:44
谢谢分享 正好在用这个
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/)
Powered by Discuz! X3.2