????????????????о?
???????????? ???????[ 2010/9/15 14:47:22 ] ????????
????JUnitPer????????
???????κ?????????????Σ?????????????????????????????????JUnitPer????????JUnit??????????????Σ??????????????????????????
????JUnitPer???????????????????????????????????????????TimedTest???LoadTest???У????潫??????????
????????????е????
???????JUnit???е??????
??????????????????????????????????TestCase????TestSuite??????TestCase????????????TestSuite?????????????????Vector????
??????Eclipse?????JUnit????
??????????????????JUnit????????????????????
package junit.samples;
import junit.framework.*;
/**
* TestSuite that runs all the sample tests
*
*/
public class AllTests {
public static void main (String[] args) {
junit.textui.TestRunner.run (suite());
}
public static Test suite ( ) {
TestSuite suite= new TestSuite("All JUnit Tests");
suite.addTest(VectorTest.suite());
suite.addTest(new TestSuite(junit.samples.money.MoneyTest.class));
suite.addTest(junit.tests.AllTests.suite());
return suite;
}
}
???????Cactus???????????????
?????????????ServletTestCase?????????????в?????????????
???????????? SampleServlet.java
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
public class SampleServlet extends HttpServlet
{
public void saveToSession(HttpServletRequest request)
{
String testparam = request.getParameter("testparam");
request.getSession().setAttribute("testAttribute"?? testparam);
}
?????????? TestSampleServlet.java
import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.cactus.ServletTestCase;
import org.apache.cactus.WebRequest;
public class TestSampleServlet extends ServletTestCase
{
public TestSampleServlet(String theName)
{
super(theName);
}
public static Test suite()
{
return new TestSuite(TestSampleServlet.class);
}
public void beginSaveToSessionOK(WebRequest webRequest)
{
webRequest.addParameter("testparam"?? "it works!");
}
public void testSaveToSessionOK()
{
SampleServlet servlet = new SampleServlet();
servlet.saveToSession(request);
assertEquals("it works!"?? session.getAttribute("testAttribute"));
}
}
??????
???·???
??????????????????
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