This repository has been archived by the owner on Aug 27, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#2 base implementation for retrieving error count from soapui runner
- Loading branch information
1 parent
e5e3598
commit e5f656e
Showing
4 changed files
with
447 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
src/main/java/org/ktc/soapui/maven/extension/impl/ErrorHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.