CSDN博客

img 0developer

J2EE逻辑测试解决方案 - JTracker

发表于2003/11/12 23:59:00  852人阅读

                 J2EE逻辑测试解决方案 - JTracker

背景:

    当前的java软件开发中,对于功能级测试,例如测试一个函数所实现的功能,我们用JUnit的测试框架很方便的解决。但当我们对程序的质量有进一步的要求时,当我们需要测试函数内部的执行逻辑,来确认实际的程序逻辑与设计书一致性时,我们需要一个白盒逻辑测试工具。本文介绍通过逻辑测试工具JTracker来解决这个问题。

JTracker 逻辑测试软件 http://jtracker.net

JTracker 逻辑测试工具是一款用于测试发布于服务器端(如Weblogic, Websphere)的 EJB组件Servlet以及 Beans或普通的Java类的白盒测试工具: 

         1. 支持函数入口`,函数出口,和函数内部特定行的逻辑测试。

         2. 支持类成员变量,局部变量值的显示,修改,支持。

         3. 支持远程测试

 

测试方案:

使用蓝图:

测试图:

 

java源代码中需要测试的位置加入逻辑测试点: 

 package testservlet;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;

public class sample extends HttpServlet {
...
static int count=0;
/*<<<TPID=TP110>>>*/        //
<< =============== logical test point,the test ID is TP110 
public void init() throws ServletException {
}

public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
...
PrintWriter out = response.getWriter();
out.println("<html>");
/*<<<TPID=TP211> >>*/       //
<< ===============  logical test point,the test ID is TP211 
count++;
out.println("<head><title>sample</title></head>");
out.println("<body>");
out.println("<p>The servlet has received a GET. This is the reply.</p>");
out.println("</body></html>");
/*<<<TPID=TP222>>>*/        //
<< ===============  logical test point,the test ID is TP222 
}
/*<<Clean up resources>>*/
public void destroy() {
}
}

 

根据不同情况编写测试每个CASE          

TestCase001.tc //Normal CASE001...
TestCase002.tc //NormalCASE002...
...

  TestCase001.tc:

////////test CASE info//////// 
caseInfo{
title = normal basic case;                                           //test case title
path =
D:/UnitTest;                                                    //test file path
source = Servlet1.java;                                               //source file name
package = testservlet;                                                //package name 
class = testservlet.Servlet1;                                       //full class name
}
////////Logic Test Point///////// 
MEnter(name=doGet){                                              //when system entry Servlet1's doGet method, it will take this logic test;
//Logic test content;
title("test1 here is doGet full name");                     //display "test1 here is doGet full name";
field.dis(intfield);                                                       //display Servlet1's field intfield;
}
MExit(name=doGet){                                                //when system exit the method Servlet1.doGet ,it willtake this logic test;
//Logic test content;
title("test1 here is doGet method name");            //display "test1 here is doGet method name";
field.dis(stringfield);                                                //display Servlet1's field stringfield;
}
BPoint(TP = TP222){                                               //when system run at test point TPSLV132, it will take this logic test;
//Logic test content;
title("TP222here");                                                   //display "TP222here";
field.dis(field3);                                                         //display Servlet1's field field3;
}

 

根据JTracker生成的测试结果文件确认程序逻辑:

TestCase001.tr //Normal CASE001...
TestCase002.tr //NormalCASE002...
...

  TestCase001.tr:

*******************************************************************
** JTracker 1.0 standard edition                                 **
** Copyright(c) 2002-2003 Chen ShiMing. All Rights Reserved.     **
**
http://www.jtracker.net                                       **
*******************************************************************
****************************** START ******************************
**************************** case info ****************************
===== CASE::: testCase001.tc =====
-------ADD::MEnter(name=doGet)
-------ADD::MExit(name=doGet)
-------ADD::BPoint(TP = TP222)
*******************************************************************
***Location::time=10:45.34.158*testservlet.Servlet1*doGet*line=51
*** Module::MEnter(name=doGet)
------------------------------
title:"test1 here is doGet full name"
dis : intfield=1 
===================================================================
***Location::time=10:45.34.259*testservlet.Servlet1*doGet*line=99
*** Module::BPoint(TP = TP222)
------------------------------
title:"TP222here"
dis : field3=3 
===================================================================
***Location::time=10:45.34.339*testservlet.Servlet1*doGet*line=146
*** Module::MExit(name=doGet)
------------------------------
title:"test1 here is doGet method name"
dis : stringfield=string 
===================================================================
******************************** END ******************************

JTracker所能带来的收益:

1  提供软件测试高质量的保证和依据。测试Case文件和JTracker产生的测试结果文件将成为一种测试的纳品和依据,对于做软件外包业务的企业的企业,将很好的提高您软件开发的品质以及在软件服务的竞争力。

2  减少测试成本,提高测试效率,缩短软件的开发周期。由于服务器端软件测试的特殊性,以前我们很难完整快速的进行测试以及产生报告,现在JTracker 逻辑测试工具帮助您自动方便的进行远程测试并且生成测试报告,这样就大大缩短了测试时间、测试文档时间以及测试的难度。

3  快速、直接、方便的查看错误状态和原因, 定位软件中的问题所在。

 

0 0

相关博文

我的热门文章

img
取 消
img