When I use android UiAutomator for testing, I find that the use cases often fail because of the slow loading of pages or the large network latency or unexpected circumstances, but they can run successfully when checking. I put forward a need to make the failed use cases run again. After trying, I finally succeed. Using excel as the type of test report, html Similarly, the following share of the running code for your reference.
List<String[]> firstsheet = new ArrayList<String[]>();//Create a new list to store test results for each test case String[] title = {"number", "Use case name", "running state", "error message", "Wrong row Library", "Wrong row Special", "Wrong row Case", "start time", "End time"}; firstsheet.add(title);//Add the header row to the table information first new RunHelper(jarname, "1");//Compile the new jar package and push to the phone. setMobileInputMethodToUtf();//Set the phone input method to UTF-7 for(int i = 0;i < MethodList.size(); i++){//Traverse through all methods String[] result = execCmdAndReturnResult(jarname, "student.Case", MethodList.get(i), i);//Running test cases firstsheet.add(result);//Put the test results of this use case into the list } List<String[]> secondsheet = new ArrayList<String[]>();//Create a new list to store the second test results secondsheet.add(title);//Add the title to the table //Traverse the first test result for(int s =0;s < firstsheet.size();s++){ String[] result = firstsheet.get(s);//Traversing the results of each use case if (!result[2].equals("Successful operation")) {//Get a set of unsuccessful use cases String[] second = execCmdAndReturnResult(jarname, "student.Case", result[1], s);//Rerun unsuccessful use cases secondsheet.add(second);//Add the results of the second run to the second table } } Map<Integer, List<String[]>> report = new HashMap<Integer, List<String[]>>();//Create a new map to store multiple table data report.put(1, firstsheet);//Put the test data of the first table into the map report.put(2, secondsheet);//Put the test data of the second table into the map to be written Excel.writeXlsx(report);//Write test reports into excel tables
The notes are a little messy this time. We will have a look at them. I hope they can help you.
Selection of previous articles
- One line of java code prints a heart
- Linux performance monitoring software netdata Chinese version
- Interface Test Code Coverage (jacoco) Scheme Sharing
- Performance testing framework
- How to Enjoy Performance Testing on Linux Command Line Interface
- Graphic HTTP Brain Map
- Writing to everyone about programming thinking
- How to Test Probabilistic Business Interface
- httpclient handles multi-user simultaneous online
- Ten Steps to Become a Great Java Developer
- Automatically convert swagger documents into test code