This article is a mirror article of machine translation, please click here to jump to the original article.

View: 10165|Reply: 2

[Software Testing] junit test code documentation Unit testing framework for Java language

[Copy link]
Posted on 3/29/2015 7:40:59 PM | | |
  1. Service.Java
  2. package bo;
  3. public class Service {
  4. public String calculate(int a, int b,int c) {
  5.         String result=null;
  6.         if(a+b<=c || a+c<=b || b+c<=a){
  7.                 result="非三角形";
  8.         }
  9.         else if(a==b && b==c && a==c){
  10.                 result="等边三角形";
  11.         }
  12.         else if(a!=b && a!=c && b!=c) {
  13.                 result="一般三角形";        
  14.         }
  15.         else {
  16.                 result="等腰三角形";
  17.         }
  18.         return result;
  19. }
  20. }


  21. ServiceTest.java
  22. package bo;
  23. import junit.framework.TestCase;
  24. public class ServiceTest extends TestCase {
  25.         protected void setUp() throws Exception {
  26.                 super.setUp();
  27.         }
  28.         public void testCalculate() {
  29.                 Service service =new Service();
  30.                 assertEquals("等边三角形", service.calculate(1, 1, 1));
  31.                 assertEquals("非三角形", service.calculate(1, 1, 2));
  32.                 assertEquals( "一般三角形", service.calculate(3, 4, 5));
  33.                 assertEquals("等腰三角形", service.calculate(2, 2, 3));
  34.         }

  35. }
Copy code


junit白盒测试.zip (1.18 MB, Number of downloads: 0, Selling price: 1 Grain MB)




Previous:Oracle Functions Help Documentation
Next:Beginner's introduction to discuz plugin development is super detailed
Posted on 12/23/2015 4:08:45 PM |
                It seems to be very profound, and I can't understand it at all                       
Posted on 12/23/2015 5:43:42 PM |
Barefoot Miao Qing Posted on 2015-12-23 16:08
It seems to be very profound, and I can't understand it at all

I am also me too
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com