what will you do if test script fails code example

Example 1: what will you do if test script fails

In my experience, I will identify the failure,
o if it is this due to application error,
sync error, script issue or environment 
is down, first of all I analyze the result by
reproduce it through Jenkins run only the fail one,
o if it is due to synchronization issue, 
I will add extra time by using implicit, 
explicit and some custom expected
conditions,
o If it is script issue I will debugging 
(identify) my script and fix it, analyze the exceptions,
o if it is real defect then I will log defect.

Example 2: how do you run failed tests

- I use a cucumber plugin that is called "rerun",
which allows me to run ONLY failed test cases.

-     How did I achieve that is:
	- I created a second runner class and
      name it FailedTestRunner which dedicated
      to running only failed scenarios.
	- Let's say I have 100 tests running in the 
      first run and ten of those tests are failed.
	- If we implemented "rerun" structure correctly,
      all of the failed tests are going to be
      stored in "rerun.txt"
	- Our "FailedTestRunner" class will be pointing
     to "rerun.txt", and when we run it,
     it will only run those failed tests.
     
     
FOR TESTNG:
I would use testng-failed.xml file to execute
failed test cases
1. After the first run of an automated test run.
Right click on Project and click on Refresh

2. A folder will be generated named
“test-output” folder. Inside “test-output”
folder, you could find “testng-failed.xml”

3. Run “testng-failed.xml” to execute 
the failed test cases again. Right-click
on this file and click on run as and 
select the option called "testNG suite".

Tags:

Misc Example