src/test/java/com/xceptance/neodymium/tests/NeodymiumTest.java
/**
     * Basic method to perform assertions on a given test result.
     * 
     * @param result
     *            test result to validate
     * @param expectSuccessful
     *            the test result should be successful
     * @param expectedRunCount
     *            expected number of run tests (including ignored)
     * @param expectedIgnoreCount
     *            expected number of ignored tests
     * @param expectedFailCount
     *            expected number of failed tests
     * @param expectedFailureMessages
     *            expected failure messages mapped by name of test method
     */
Basic method to perform assertions on a given test result.


Basic method to perform assertions on a given test result .
public void check(final Result result, final boolean expectSuccessful, final int expectedRunCount, final int expectedIgnoreCount,
                      final int expectedFailCount, final Map<String, String> expectedFailureMessages)
    {
        final Optional<String> accumulatedTrace = result.getFailures().stream().map(Failure::getTrace).reduce(String::concat);
        final String stackTrace = accumulatedTrace.orElse("n/a");
        try
        {
            Assert.assertEquals("Test successful", expectSuccessful, result.wasSuccessful());
            Assert.assertEquals("Method run count", expectedRunCount, result.getRunCount());
            Assert.assertEquals("Method ignore count", expectedIgnoreCount, result.getIgnoreCount());
            Assert.assertEquals("Method fail count", expectedFailCount, result.getFailureCount());
            if (expectedFailureMessages != null)
            {
                final int failureCount = result.getFailureCount();
                for (int i = 0; i < failureCount; i++)
                {
                    final String methodName = result.getFailures().get(i).getDescription().getMethodName();
                    Assert.assertEquals("Failure message", expectedFailureMessages.get(methodName), result.getFailures().get(i).getMessage());
                }
            }
        }
        catch (AssertionError e)
        {
            Assert.fail("Assertion failed. " + e.getMessage() + " Stack trace: " + stackTrace);
        }
    }
public void check ( final Result result , final boolean expectSuccessful , final int expectedRunCount , final int expectedIgnoreCount , final int expectedFailCount , final Map < String , String > expectedFailureMessages ) { final Optional < String > accumulatedTrace = result . getFailures ( ) . stream ( ) . map ( Failure :: getTrace ) . reduce ( String :: concat ) ; final String stackTrace = accumulatedTrace . orElse ( "n/a" ) ; try { Assert . assertEquals ( "Test successful" , expectSuccessful , result . wasSuccessful ( ) ) ; Assert . assertEquals ( "Method run count" , expectedRunCount , result . getRunCount ( ) ) ; Assert . assertEquals ( "Method ignore count" , expectedIgnoreCount , result . getIgnoreCount ( ) ) ; Assert . assertEquals ( "Method fail count" , expectedFailCount , result . getFailureCount ( ) ) ; if ( expectedFailureMessages != null ) { final int failureCount = result . getFailureCount ( ) ; for ( int i = 0 ; i < failureCount ; i ++ ) { final String methodName = result . getFailures ( ) . get ( i ) . getDescription ( ) . getMethodName ( ) ; Assert . assertEquals ( "Failure message" , expectedFailureMessages . get ( methodName ) , result . getFailures ( ) . get ( i ) . getMessage ( ) ) ; } } } catch ( AssertionError e ) { Assert . fail ( "Assertion failed. " + e . getMessage ( ) + " Stack trace: " + stackTrace ) ; } }
Basic method to perform assertions on a given test result.
Basic method to perform assertions on a given test result .