Kook Testjs v1.0
来源:互联网 发布:翻墙方法 知乎 编辑:程序博客网 时间:2024/05/21 11:26
源代码:
测试:
html
- /**
- *
- *@function 测试用例
- *@time 2008-12-10
- *@author Kyle
- *@version 1.0
- */
- function TestCase(){
- }
- /**
- *@function 初始化测试用例
- *@scope protected
- */
- TestCase.prototype.setUp=function(){};
- /**
- *@function 执行函数
- *@scope public
- */
- TestCase.prototype.run=function(){
- this.setUp();//运行前调用setUP()方法以初始化用例
- };
- TestCase.prototype.assertNotNull=function(/*Object */obj){
- if(obj==null)
- throw "><b><font color=red> assertNotNull()</font>></b>Object:<b><font color=red>"+obj+"</font></b> is null ";
- };
- /**
- *@function 用例加载器
- */
- function TestRunner(){}
- /**
- *@function 异常处理
- */
- TestRunner.prototype.exception=function(/*Object*/obj,/*exception function property name list*/list){
- if(!list){
- list=[];
- }
- for(var prop in obj){
- /*
- *如果开始包含test字符串,且是function类型
- *@note 效率需要改进
- */
- if(prop.indexOf("test")==0&&typeof(obj[prop])=="function"){
- try{
- obj[prop]();
- list.push("<div><b><font color=green>"+prop+"() is ok</font></b><div>");
- }catch(e){
- list.push("<div><B><font color=red><b>"+prop+"()</font></b>>"+e+"</font><div>");
- }
- }
- }
- var div = document.createElement("div");
- div.innerHTML=list.join("<br>");
- document.body.appendChild(div);
- };
- /**
- *@function 用于运行用例
- */
- TestRunner.prototype.run=function(/*TestCase function*/testCase){
- var obj=new testCase;
- obj.run();
- this.exception(obj,null);
- };
- var Runner=new TestRunner;
- var testCase1=function(){};
- testCase1.prototype=new TestCase;
- testCase1.prototype.testHelloWorld=function(){
- this.assertNotNull(null);
- };
- testCase1.prototype.testHelloWorld2=function(){
- this.assertNotNull(null);
- };
- testCase1.prototype.testHelloWorld3=function(){
- this.assertNotNull("sdf");
- };
- testCase1.prototype.setUp=function(){
- alert("this is a init");
- };
- Runner.run(testCase1);
- <script src="Test.js"></script>
- <body>
- <script src="TestCases.js"></script>
- </body>
- Kook Testjs v1.0
- Kook ajax v1.0
- Kook $ v1.0.2
- testJS
- V1.0
- 定时关机 v1.0(autoshut v1.0)
- 霹雳短信v1.0
- 超级俄罗斯方块V1.0
- WinEggDrop v1.0 源代码
- VB decompiler v1.0
- fhs v1.0 reversed
- Process Monitor v1.0
- MP3bar v1.0 发布
- Obfuscator v1.0
- 发布SnifferFox v1.0
- WinMount v1.0
- [原创]FlexWebXP V1.0
- 易选双色球 v1.0 免费
- dos batch file in windows
- 你是最适合创业的程序员吗?
- IT世界里,所有的发明都是用来被推翻的!java也好,.NET也罢,都无法逃脱这样的宿命
- Oracle存储过程
- SQL注入的防止--使用preparedStatement
- Kook Testjs v1.0
- 成功学习英语
- [英语阅读]机场安检会对身体有害吗
- 文件夹大小列表 TreeSize Free + Folder Size for Windows
- 怎么让搜索出来的关键字变红色?
- [双语阅读]总统模拟游戏即将出炉 玩家试当奥巴马
- 用split实现多关键字的搜索
- Ubuntu安装图解(转)
- 一个搜索条效果