Given a test failure how can you extract all code statements that the test execution ran?

60 views Asked by At

Given a test failure, I have to extract all code statements that the test execution ran.

Let's say unit test 1 has failed. I have to extract all the codes it executed.

public class Driver {

  method1 {
  }  

  method2 {
  }  

  method3 {
  }  

  public TakeScreenshot(int flag){
     statement1;
     statement2;
     
     if(flag) {
       statement_inside_flag;
     }
    

     statement100;
  }
}
[TestMethod]
public void TestThings()
{
        boolean result = Driver.TakeScreenshot(true);
        Assert.isTrue(result);
}

Is there an easy way I can do it using an open-source tool?

If I want to extract the body of the code under test i.e. in this case the output would be as follows. Some lines in the TakeScreenshot was not executed:

public class Driver {
  public TakeScreenshot(int flag){
     statement1;
     statement2;
     
     if(flag) {
       statement_inside_flag;
       return;
     }
  }
}
0

There are 0 answers