UrbanCode

Reflecting proper Test status in UCD Test Plugin 

Tue October 13, 2020 01:48 PM

Urbancode Deploy will pass the status of a step up to the overall process depending on whether that step is successful or not. 

When using the Rational Functional Tester plugin the step will be marked success if the test were able to run, not whether the tests passed or failed.   This could result in a failed test being buried inside the process and require drilling into the log to see if it passed or failed.

The code below will parse the UrbanCode log file and set the step status based on the test results


Add this code as a post processing script for the Functional Test step.  This code will also highlight the line in the log that shows the test result.

var exit = properties.get('exitCode');
var beginCheck = 0;
var testFailed = 0;
properties.put('TestResult', 'PASS');

scanner.register("Running test", function(lineNumber, line) {
   beginCheck = 1;
});

scanner.register("Test Result = FAIL", function(lineNumber, line) {
   if (beginCheck == 1) {
      properties.put('TestResult', 'FAIL');
      testFailed = 1;
      properties.put('Status', 'Failure');
   }
});

if (exit == 0) {
   properties.put('Status', 'Success');
   scanner.scan();
}

else {
   properties.put('Status', 'Failure');
}​


After the Functional Test step you can then add a step to fail the process if the tests fail

Statistics

0 Favorited
14 Views
0 Files
0 Shares
0 Downloads