代理代码调试的实现日志

Functional Tester 提供日志基础结构,调试开发代理代码时,您可以使用此结构。 FTDebug 类可用于 Java™ 和 .Net 代理开发框架中。 您可以针对每种代理类,将 FTDebug 类的对象进行实例化,并分类记录所有信息、警告或错误消息。

开始之前

此示例代码显示如何在 Java 中实现对代理代码的日志记录:

import com.rational.test.ft.util.FtDebug;
.
public class MyProxy extends BaseProxy
{
	protected static FtDebug debug = new FtDebug("myproxies");
	.
	void anyMethod()
	{
		debug.trace("Beginging of anyMethod()");
		.
		debug.verbose("I'm doing this!");
		.
		debug.warning("Not critical, good to have it fixed");
		.
		debug.error("I shouldn't have been here!!") ;
		.
		debug.trace("End of anyMethod()");
	}
}

此示例代码显示如何在 .Net 中实现对代理代码的日志记录:

.
using Rational.Test.Ft.Util;
.
public class MyProxy : BaseProxy
{
	protected static FtDebug debug = new FtDebug("myproxies");
	.
	void anyMethod()
	{
		debug.Trace("Beginging of anyMethod()");
		.
		debug.Verbose("I'm doing this!");
		.
		debug.Warning("Not critical, good to have it fixed");
		.
		debug.Error("I shouldn't have been here!!") ;
		.
		debug.Trace("End of anyMethod()");
	}
}

在此示例中,FtDebug() 方法传递 myproxies 字符串。 您可以在 C:\Program Files\IBM\SDP70\FunctionalTester\bin\ 目录下的 ivory.properties 文件中使用此字符串,来控制执行时发出的日志信息的级别。此示例代码显示如何在 ivory.properties 文件中使用 myproxies 字符串:

###
### Debugging options
###
# The following propeties are used to control the debugging output generated by the FT
# product.  In production versions this output is minimal, limited primarily to error
# and warning level information.
rational.test.ft.debug.enabled=true
rational.test.ft.debug.clear_on_init=false
rational.test.ft.debug.filename=c:/ivDebug.txt
# filter levels: error,0;warning,1;debug,2;verbose,3
rational.test.ft.debug.filter=default,1;myproxies,3;
在本示例中,将 myproxies 字符串值设置为 3。这样,您可以控制写入到 ivDebug.txt 文件中的调试信息的级别。

反馈