Skip to content
This repository has been archived by the owner on Aug 27, 2021. It is now read-only.

Commit

Permalink
#2 base implementation for retrieving error count from soapui runner
Browse files Browse the repository at this point in the history
  • Loading branch information
redfish4ktc committed Apr 6, 2012
1 parent e5e3598 commit e5f656e
Show file tree
Hide file tree
Showing 4 changed files with 447 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package org.ktc.soapui.maven.extension.impl;

import java.lang.reflect.Field;
import java.util.List;

import org.apache.commons.lang3.reflect.FieldUtils;

import com.eviware.soapui.model.testsuite.TestAssertion;
import com.eviware.soapui.model.testsuite.TestCase;
import com.eviware.soapui.tools.SoapUITestCaseRunner;

public class ErrorHandler {

public static boolean hasErrors(SoapUITestCaseRunner runner) {
List<TestCase> failedTests = getFailedTests(runner);
if (failedTests.size() > 0) {
return true;
}
List<TestAssertion> failedAssertions = getFailedAssertions(runner);
if (failedAssertions.size() > 0) {
return true;
}

return false;
}

private static List<TestCase> getFailedTests(SoapUITestCaseRunner runner) {
String fieldName = "failedTests";
Field field = FieldUtils.getField(SoapUITestCaseRunner.class, fieldName, true);
try {
@SuppressWarnings("unchecked")
List<TestCase> failedTests = (List<TestCase>) FieldUtils.readField(field, runner, true);
return failedTests;
}
catch (IllegalAccessException e) {
throw new RuntimeException("Unable to read field " + fieldName, e);
}
}

private static List<TestAssertion> getFailedAssertions(SoapUITestCaseRunner runner) {
String fieldName = "assertions";
Field field = FieldUtils.getField(SoapUITestCaseRunner.class, fieldName, true);
try {
@SuppressWarnings("unchecked")
List<TestAssertion> failedAssertionss = (List<TestAssertion>) FieldUtils.readField(field, runner, true);
return failedAssertionss;
}
catch (IllegalAccessException e) {
throw new RuntimeException("Unable to read field " + fieldName, e);
}
}

}
Loading

0 comments on commit e5f656e

Please sign in to comment.