• softwareTesting_work2_question2


    1. work2类
       1 package com.Phantom;
       2 
       3 import java.util.Scanner;
       4 
       5 import javax.print.DocFlavor.INPUT_STREAM;
       6 
       7 public class work2 {
       8     String str=null;
       9     StringBuffer re_str=null;
      10     
      11     public String getStr() {
      12         return str;
      13     }
      14 
      15     public void setStr(String str) {
      16         this.str = str;
      17     }
      18 
      19     public StringBuffer getRe_str() {
      20         return re_str;
      21     }
      22 
      23     public work2() {
      24         super();
      25     }
      26 
      27     public String input(){
      28         System.out.println("请输入内容:");
      29         //str = "how are you";
      30         String strs[] = str.split(" ");
      31         re_str = new StringBuffer();
      32         for(int i = strs.length-1; i >= 0; i--){
      33             //测试
      34             //System.out.println(strs[i]);
      35             re_str.append(" "+strs[i]);
      36         }
      37         System.out.println("输出:"+re_str);
      38         return re_str.toString();
      39     }
      40 
      41 }
    2. testing类
       1 package com.Phantom;
       2 
       3 import static org.junit.Assert.*;
       4 import junit.framework.TestCase;
       5 
       6 import org.junit.After;
       7 import org.junit.Before;
       8 import org.junit.Test;
       9 
      10 public class testing extends TestCase {
      11 
      12     private work2 w;
      13     @Before
      14     public void setUp() throws Exception {
      15         super.setUp();
      16         w=new work2();
      17     }
      18 
      19     @After
      20     public void tearDown() throws Exception {
      21         System.out.println("w.getStr()>>>"+w.getStr());
      22         System.out.println("w.getRe_str()>>>"+w.getRe_str());
      23     }
      24 
      25     @Test
      26     public void test() {
      27     //    fail("Not yet implemented");
      28         w.setStr("as sa");
      29         w.input();
      30         assertTrue(w.getRe_str().toString()=="sa as");}
      31 
      32 }

    junit

    覆盖率

  • 相关阅读:
    数学建模反思
    [Leetcode]unique binary search trees
    暑假结束了,开始新的学习
    什么是lamda表达式?
    [Java]三大特性之封装
    [Leetcode]003. Longest Substring Without Repeating Characters
    [Leetcode] 002. Add Two Numbers
    [Leetcode] 001.Two Sum
    [数据结构]AVL树
    [数据结构]二叉搜索树
  • 原文地址:https://www.cnblogs.com/Phantom-void/p/5322969.html
Copyright © 2020-2023  润新知