php 测试类

WBOY
Release: 2016-06-23 14:33:31
Original
1195 people have browsed it

 今天写了一个测试的php类。 

这个对于单元测试很方便。 但是对于参数的处理,我感觉代码很丑陋,有没有高手帮忙,美化一下。

 

参数始终不可以动态。 

 

 //调用  Test("365",$className ,   "DateDiff",array( "2013-8-4","2012-8-4")); 

 1#region   Test   2 3     
 4     function Test($expected,$className,$functionName,$parameteres )
 5     {
 6         
 7         switch(sizeof($parameteres))
 8         {
 9             case 0:
10                 $actual= call_user_func(array($className,$functionName)  );
11                 break;
12             case 1:
13                 $actual=  call_user_func(array($className,$functionName),$parameteres[0] );
14                 break;
15             case 2:
16                 $actual=  call_user_func(array($className,$functionName),$parameteres[0],$parameteres[1] );
17                 break;
18             case 3:
19                 $actual=  call_user_func(array($className,$functionName),$parameteres[0],$parameteres[1],$parameteres[2] );
20                 break;
21         }            
22         if($expected==$actual   )
23         {
24             echo  "Passed Result: $functionName expected: $expected vs actual  $actual
";
25         }
26         else
27         {
28             echo  " Failed Result: $functionName  expected:  $expected vs actual $actual
";
29         }
30     }
31 
32  
45     #endregion

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template