Conclusion:
Fitnesse is a very creative software. It tries to narrow the distance between developers and users. According to the previous introduction, we may also see that the Code (fixture) should be implemented in the end. These codes are generally written by testers. Some of my thoughts are triggered:
1. Is there any need to develop an acceptance form for each requirement ". If you do this, you need to write a lot of fixture. Writing these codes takes considerable time, and time is expensive. Is there a way to reduce the cost when the results are roughly the same?
2. Are there any bugs in the Code itself? Do I have to pay more for debugging the code and maintaining it in the future? -- I used to be very keen on the development of automated testing, but later I observed that if a piece of automated testing code is written and executed only a few times, then I think this automation is meaningless.
Iii. Therefore, my opinion is that automation is only applicable to tests that require a large amount of regression, fixed functions, and a relatively low level. The testing code should be as simple as possible; do not add complex logic as much as possible; use it whenever possible to improve utilization; spend as little time as possible.
Based on the above understanding, I will provide a general fixture and fitnesse table, which is mainly used for interface testing in our company and can also be used for general page checks. It will take nearly two years for the actual operation, and the effect is acceptable. Some built-in fixture of fitnesse should have similar functions, but I think it may take longer to search for and learn to use than to write for myself.
package calis.http;import org.apache.http.impl.client.*;import org.apache.http.client.methods.*;import org.apache.http.HttpEntity;import org.apache.http.HttpResponse;import org.apache.http.util.EntityUtils;public class Exist {private String url=null;private String key=null;private String keys[]=null;private String reponseStr;private String result="NotExist";public void setStartUrl(String url){this.url=url;}public void setKeyWords(String s){key=s;if(key.charAt(0)!='/'){key="/"+key;}keys=key.split("/");}public String verify(){return result;}public void execute(){DefaultHttpClient httpclient = new DefaultHttpClient();HttpGet httpget = new HttpGet(url);try{HttpResponse response = httpclient.execute(httpget);HttpEntity entity = response.getEntity();if (entity != null) {reponseStr=EntityUtils.toString(entity,"UTF-8");if(keys.length>1){boolean judge=true;for(int i=1;i<keys.length;i++){if(reponseStr.contains(keys[i])){judge=judge&&true;}else judge=false;}if(judge){result="ok";}}}}catch(Exception e){result="NoExist";}finally{httpclient.getConnectionManager().shutdown();}}public void reset(){result="NoExist";}}
The table is as follows:
CALIS. http. exist |
Start URL |
Key Words |
Verify? |
Http://cn.bing.com/search? Q = % E4 % B8 % ad % E5 % 9B % BD |
China/People's Republic of China |
OK |
Http://www.126.com |
Email account logon/Dynamic Password Logon |
OK |
...... |
...... |
OK |
It is easy to use. Enter the address in the Start URL and check whether all the returned strings contain the strings specified by key words. Each string is separated by a slash. If all items contain OK, not all items return noexist. Although simple, it is very common and can be used to detect all HTML, XML, JSON, and other returned results that support rest requests.
Known issues in the above Code are:
1. Non-UTF-8 format return is not supported
2. Only "and" checks are supported. Other logical relationships with keywords are not supported.
3. The escape characters on the HTML are not processed. For example, if the escape characters are displayed as <on the page, the encoding is & lt, so check & lt instead of <
4. The start URL is not encoded. For example, if there is a space, an exception occurs. In this case, manually change to % 20.
5. Because the keywords are separated by/, it is impossible to check whether the returned values contain.
As I have always insisted on, the test code should be as simple as possible, and I have no intention of improving this content.
Fitnesse Series 8