cucumber

Recent boss needs a cucumber test project, as colleagues are not familiar with the code can be written using test cases. So I was forced to learn in contact for some time.

cucumber Given When Then write feature with keywords, so use cucumber when you need to design the logical structure of a good feature: eg

 

 

 call api can rest-assured jar to implement, support jsonpath (rest-assured that comes jsonpath, you can also use

<!--<dependency>-->
<!--<groupId>com.jayway.jsonpath</groupId>-->
<!--<artifactId>json-path</artifactId>-->
<!--<version>2.4.0</version>-->
<!--</dependency>-->

). And cucumber embedded Gson, also supports multi-threading fyi. But for complex json structure, write up more trouble, difficult to achieve. So when I embodied in the project, is to deal with the object into json, flexibility is not enough, but the process is simple and easy.

Some typical problems encountered in the project, to share records about:

When the object 1 json turn, date conversion error

Solution 1 target date in the types of properties into String

         2 to remove the date data in json

String json1 = str.replaceAll (([0-9 ] {4}) "* \." - ([0-9] {2}) - ([0-9] {2}) T ([0-9 ] {2}): ([0-9] {2}): ([0-9] {2}) \ ",", "\ n-"); 
String json2 = json1.replaceAll ( ", \ n-. * \ "([0-9] { 4}) - ([0-9] {2}) - ([0-9] {2}) T ([0-9] {2}): ([0 -9] {2}): ([0-9] {2}) \ "", "\ n-");
String json3 = json2.replaceAll ( "* \" ([0-9] {}. 4). - ([0-9] {2}) - ([0-9] {2}) \ ",", "\ n-");
String JSON json3.replaceAll = (([ ", \ n-* \." 0-9] {4}) - ( [0-9] {2}) - ([0-9] {2}) \ "", "\ n");
at the time of treatment should be noted json comma issues, such as dealing
"date1": "2015-05-05T00: 00: 00",

"that represented by DATE2": "2015-05-05T00:: 00 00"
, the first is the need to remove the trailing comma, second a comma is not the tail, but the need to remove the front of the comma.

2 java.lang.SecurityException:

Solution:

 

 3 javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path exception when call api.

Solution:

 

 Being so much

 

 

Guess you like

Origin www.cnblogs.com/Jenny22/p/12195871.html