Java 类org.testng.asserts.IAssert 实例源码

项目:WebAuto    文件:LoggerUtil.java   
public void assertion(String status, IAssert assertCommand) {
    String expected = assertCommand.getExpected().toString();
    String actual = assertCommand.getActual().toString();
    String msg = assertCommand.getMessage();

    if (expected != null) {
        seltest.info("|-{} :- EXPECTED =  '{}' , ACTUAL = '{}' ", status,
                expected, actual);
        report.reportAssert("ASSERT " + status.toLowerCase(), expected,actual);
    } else if (msg != null) {
        seltest.info("|-{} :- Message : {}  ", status, msg);
        report.reportAssert("ASSERT " + status.toUpperCase(), msg, "");
    } else {
        seltest.info("|-{} ", status);
        report.reportAssert("ASSERT " + status.toUpperCase(), "", "");
    }

}
项目:WebAuto    文件:SoftAssertion.java   
public void assertAll() {
    if (!m_errors.isEmpty()) {
        StringBuilder sb = new StringBuilder(
                "The following asserts failed:\n");
        boolean first = true;
        for (Map.Entry<AssertionError, IAssert> ae : m_errors.entrySet()) {
            if (first) {
                first = false;
            } else {
                sb.append(", ");
            }
            sb.append(ae.getValue().getMessage());
        }
        throw new SkipException("Verification Failures : " + sb.toString());
    }
}
项目:testng_samples    文件:SoftHamcrestAssert.java   
public <T> void assertThat(final T actual, final Matcher<? super T> matcher) {
  doAssert(new IAssert() {
    @Override
    public void doAssert() {
      MatcherAssert.assertThat(actual, matcher);
    }

    @Override
    public Object getActual() {
      return actual;
    }

    @Override
    public Object getExpected() {
      return null;
    }

    @Override
    public String getMessage() {
      return null;
    }
  });
}
项目:testng_samples    文件:SoftHamcrestAssert.java   
public <T> void assertThat(final String reason, final T actual, final Matcher<? super T> matcher) {
  doAssert(new IAssert() {
    @Override
    public void doAssert() {
      MatcherAssert.assertThat(reason, actual, matcher);
    }

    @Override
    public Object getActual() {
      return actual;
    }

    @Override
    public Object getExpected() {
      return null;
    }

    @Override
    public String getMessage() {
      return reason;
    }
  });
}
项目:seletest    文件:SoftAssert.java   
/**
 * Assert failures after test execution
 */
public void assertAll() {
    if (! m_errors.isEmpty()) {
        StringBuilder sb = new StringBuilder("The following asserts failed:\n");
        boolean first = true;
        for (Map.Entry<AssertionError, IAssert> ae : m_errors.entrySet()) {
            if (first) {
                first = false;
            } else {
                sb.append(", ");
            }
            sb.append(ae.getKey());
        }
        //set the test as failed
        Reporter.getCurrentTestResult().setStatus(ITestResult.FAILURE);
        org.testng.Reporter.setCurrentTestResult(Reporter.getCurrentTestResult());
        m_errors.clear();
    }
}
项目:heat    文件:CustomSoftAssert.java   
@Override
public void executeAssert(IAssert a) {
    errorsRetrieved = new HashMap<>();
    try {
        a.doAssert();
    } catch (AssertionError ex) {
        onAssertFailure(a, ex);
        errorsRetrieved.put(ex, a);
    }
}
项目:WebAuto    文件:SoftAssertion.java   
@Override
public void executeAssert(IAssert a) {
    try {
        report.reportAssert("VERIFY : " + a.getMessage(), a
                .getExpected().toString(), a.getActual().toString());
        a.doAssert();
    } catch (AssertionError ex) {
        onAssertFailure(a, ex); // TODO Need to Remove 4 times logging
        m_errors.put(ex, a);
    }
}
项目:seletest    文件:SoftAssert.java   
@Override
public void executeAssert(IAssert a) {
    try {
        a.doAssert();
        log.info("[EXPECTED]:"+a.getExpected()+" [ACTUAL]:"+ a.getActual()+"***** ----> VERIFICATION: "+a.getMessage(),"color:green; margin-left:20px;");
    } catch(AssertionError ex) {
        log.verificationError("*****[EXPECTED]:"+a.getExpected()+" [ACTUAL]:"+ a.getActual()+"***** ----> VERIFICATION: "+a.getMessage()+ "------StackTrace:\\n"+findLineExceptionOccured(ex));
        onAssertFailure(a, ex);
        m_errors.put(ex, a);
    }
}
项目:heat    文件:CustomSoftAssert.java   
public Map<AssertionError, IAssert> getErrorsRetrieved() {
    return errorsRetrieved;
}
项目:WebAuto    文件:HardAssertion.java   
@Override
public void onAssertFailure(IAssert assertCommand, AssertionError ex) {
    logger.assertion(" (ASSERT FAILED) ", assertCommand);
    throw new AssertionError(ex);
}
项目:WebAuto    文件:HardAssertion.java   
@Override
public void onAssertSuccess(IAssert assertCommand) {
    logger.assertion("  (ASSERT SUCCESS) ", assertCommand);
}
项目:WebAuto    文件:HardAssertion.java   
@Override
public void onAfterAssert(IAssert assertCommand) {
    // Not Implemented
}
项目:WebAuto    文件:HardAssertion.java   
@Override
public void onBeforeAssert(IAssert assertCommand) {
    // Not Implemented
}