• 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

    覆盖率

  • 相关阅读:
    js语法学习(变量类型,循环,判断语句,函数)
    使用IIS Server Farms搭建应用服务负载均衡
    Vue SSR学习
    Vue-3D-Model:用简单的方式来展示三维模型
    vue中的$EventBus.$emit、$on的应用
    Vue.js系列:生命周期钩子
    浅谈vue学习之组件通信
    vue中的provide/inject讲解
    浅谈vue$router 和 $route的区别
    vue 父子component生命周期
  • 原文地址:https://www.cnblogs.com/Phantom-void/p/5322969.html
Copyright © 2020-2023  润新知