protected void doAssert(IAssert<?> assertCommand) { onBeforeAssert(assertCommand); try { executeAssert(assertCommand); onAssertSuccess(assertCommand); } catch(AssertionError ex) { onAssertFailure(assertCommand, ex); throw ex; } finally { onAfterAssert(assertCommand); } }
public void assertEquals(final String actual, final String expected) { doAssert(new SimpleAssert<String>(actual, expected) { @Override public void doAssert() { org.testng.Assert.assertEquals(actual, expected); } }); }
@Override public void onAssertFailure(IAssert<?> assertCommand, AssertionError ex) { onAssertFailure(assertCommand); }
@Override public void onAssertSuccess(IAssert assertCommand) { methods.add("onAssertSuccess"); super.onAssertSuccess(assertCommand); }
@Override public void onAfterAssert(IAssert assertCommand) { methods.add("onAfterAssert"); super.onAfterAssert(assertCommand); }
@Override public void onBeforeAssert(IAssert assertCommand) { methods.add("onBeforeAssert"); super.onBeforeAssert(assertCommand); }
/** * The assertion method is useful to manage assertion hard and soft. * @param isBlocking it is a boolean that indicates if it is necessary to use an hard assertion (true) or a soft one (false) * @param assertType it is a string that represents the name of the method to call for a normal assert (example: assertEquals, ...) * @param message it is a string representing the message related to the assertion * @param currentObjs it is the array of objects to analyse in the assertion * @return a boolean, true is the assertion is ok, false otherwise. */ public boolean assertion(boolean isBlocking, String assertType, String message, Object... currentObjs) { boolean checkOk = true; try { if (isBlocking) { Assertion hardAssertion = new Assertion(); executeAssertion(assertType, message, hardAssertion, currentObjs); } else { CustomSoftAssert softAssertion = new CustomSoftAssert(); executeAssertion(assertType, message, softAssertion, currentObjs); if (!softAssertion.getErrorsRetrieved().isEmpty()) { checkOk = false; } } } catch (NoSuchMethodException | IllegalAccessException oEx) { throw new HeatException(logUtils.getExceptionDetails() + "exception '" + oEx.getClass() + "' with message '" + oEx.getLocalizedMessage() + "'"); } catch (InvocationTargetException oEx) { //this is the exception raised in case of failure of the reflection-called method throw new HeatException(oEx.getCause().toString().split(":")[1].trim()); } return checkOk; }
@Override public void onAssertFailure(IAssert assertCommand, AssertionError ex) { methods.add("onAssertFailure"); super.onAssertFailure(assertCommand, ex); }
@Override public void onAssertSuccess(IAssert<?> assertCommand) { if (getLogger().isDebugEnabled()) { getLogger().debug(GaleniumReportUtil.MARKER_PASS, "PASSED: {} (actual: {})", assertCommand.getMessage(), assertCommand.getActual()); } super.onAssertSuccess(assertCommand); }
/** * The assertion method is useful to manage assertion hard and soft. * @param isBlocking it is a boolean that indicates if it is necessary to use an hard assertion (true) or a soft one (false) * @param assertType it is a string that represents the name of the method to call for a normal assert (example: assertEquals, ...) * @param message it is a string representing the message related to the assertion * @param currentObjs it is the array of objects to analyse in the assertion * @return a boolean, true is the assertion is ok, false otherwise. */ public boolean assertion(boolean isBlocking, String assertType, String message, Object... currentObjs) { boolean checkOk = true; try { if (isBlocking) { Assertion hardAssertion = new Assertion(); executeAssertion(assertType, message, hardAssertion, currentObjs); } else { CustomSoftAssert softAssertion = new CustomSoftAssert(); executeAssertion(assertType, message, softAssertion, currentObjs); if (!softAssertion.getErrorsRetrieved().isEmpty()) { checkOk = false; } } } catch (NoSuchMethodException | IllegalAccessException oEx) { throw new HeatException(logUtils.getExceptionDetails() + "exception '" + oEx.getClass() + "' with message '" + oEx.getLocalizedMessage() + "'"); } catch (InvocationTargetException oEx) { //this is the exception raised in case of failure of the reflection-called method throw new HeatException(oEx.getCause().toString().split(":")[1].trim()); } return checkOk; }
protected void doAssert(IAssert<?> assertCommand) { onBeforeAssert(assertCommand); try { executeAssert(assertCommand); onAssertSuccess(assertCommand); } catch (AssertionError ex) { onAssertFailure(assertCommand, ex); throw ex; } finally { onAfterAssert(assertCommand); } }
public void assertEquals(final float actual, final float expected, final float delta, final String message) { doAssert(new SimpleAssert<Float>(actual, expected, message) { @Override public void doAssert() { org.testng.Assert.assertEquals(actual, expected, delta, message); } }); }
@Override public void onAssertFailure(IAssert<?> assertCommand, AssertionError ex) { getLogger().error(GaleniumReportUtil.MARKER_FAIL, assertCommand.getMessage()); super.onAssertFailure(assertCommand, ex); }
public void assertEquals(final float actual, final float expected, final float delta) { doAssert(new SimpleAssert<Float>(actual, expected) { @Override public void doAssert() { org.testng.Assert.assertEquals(actual, expected, delta); } }); }
public void assertEquals(final char actual, final char expected, final String message) { doAssert(new SimpleAssert<Character>(actual, expected, message) { @Override public void doAssert() { org.testng.Assert.assertEquals(actual, expected, message); } }); }
public void assertEquals(final short actual, final short expected, final String message) { doAssert(new SimpleAssert<Short>(actual, expected, message) { @Override public void doAssert() { org.testng.Assert.assertEquals(actual, expected, message); } }); }
public void assertEquals(final int actual, final int expected) { doAssert(new SimpleAssert<Integer>(actual, expected) { @Override public void doAssert() { org.testng.Assert.assertEquals(actual, expected); } }); }
public void assertSame(final Object actual, final Object expected) { doAssert(new SimpleAssert<Object>(actual, expected) { @Override public void doAssert() { org.testng.Assert.assertSame(actual, expected); } }); }
public void assertNotSame(final Object actual, final Object expected, final String message) { doAssert(new SimpleAssert<Object>(actual, expected, message) { @Override public void doAssert() { org.testng.Assert.assertNotSame(actual, expected, message); } }); }
public void assertEquals(final Set<?> actual, final Set<?> expected) { doAssert(new SimpleAssert<Set<?>>(actual, expected) { @Override public void doAssert() { org.testng.Assert.assertEquals(actual, expected); } }); }