Eclipse Beginner's Notes (2)

Source: Internet
Author: User
Beginner
Use of 4.Junit







































First we add an ABS () method to the Hello class to return the absolute value







































public int abs (int n) {







































Return N>0?n: (-N);







































}







































Select Helloworld.java, right click, select New->junit Test case:







































After you ask if you want to add a Junit.jar package, Eclipse creates a new HelloWorldTest class to test the HelloWorld class.







































Select Setup () and teardown (), and then click "Next":

















































































Select the method you want to test, tick the front.

















































































Then add the test code to the HelloWorldTest:

















































































Click Run as junit and switch to JUnit on the left navigation bar. If the test passes, it will be green.







































5. Add Tomcat Application

















































































Follow the wizard. You can see that the following additions are added to the server.xml:







































<context path= "/testapp" reloadable= "true" docbase= D:\eclipse\workspace\testApp "workdir=" D:\eclipse\workspace \testapp\work\org\apache\jsp "/>







































If you right-click src to add packages and classes, the save is automatically added to the classes.







































Right-click TestApp New File index.jsp and add the following:







































<%@ page contenttype= "TEXT/HTML;CHARSET=GBK"%>





























































































































































<title>







































Helloworld







































</title>














































































<body>







































helloworld!







































</body>














































































Then start Tomcat and enter http://127.0.0.1:8080/testApp/index.jsp in the browser to see the contents of the index.






Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.