package test.assertion;

import org.testng.Assert;
import org.testng.annotations.Test;
import org.testng.asserts.IAssert;
import org.testng.asserts.SoftAssert;

import java.util.ArrayList;
import java.util.Collection;

public class SoftAssertTest {
  @Test
  public void testOnSucceedCalled() throws Exception {
    final Collection<IAssert> succeed = new ArrayList<IAssert>();
    final SoftAssert sa = new SoftAssert() {
      @Override
      public void onAssertSuccess(IAssert assertCommand) {
        succeed.add(assertCommand);
      }
    };
    sa.assertTrue(true);
    sa.assertTrue(false);
    Assert.assertEquals(succeed.size(), 1, succeed.toString());
  }

  @Test
  public void testOnFailureCalled() throws Exception {
    final Collection<IAssert> failured = new ArrayList<IAssert>();
    final SoftAssert sa = new SoftAssert() {
      @Override
      public void onAssertFailure(IAssert assertCommand, AssertionError ex) {
        failured.add(assertCommand);
      }
    };
    sa.assertTrue(true);
    sa.assertTrue(false);
    Assert.assertEquals(failured.size(), 1, failured.toString());
  }

  @Test
  public void testAssertAllCount() throws Exception {
    final SoftAssert sa = new SoftAssert();
    sa.assertTrue(true);
    sa.assertTrue(false);
    try {
      sa.assertAll();
      Assert.fail("Exception expected");
    } catch (AssertionError e) {
      final String message = e.getMessage();
      Assert.assertEquals(message.split("\r?\n").length, 2, message);
    }
  }
}

@@ -242,16 +242,17 @@
 tTest %7B%0A
+%0A
   @Test%0A
@@ -278,16 +278,26 @@
 nSucceed
+AndFailure
 Called()
@@ -362,39 +362,92 @@
 = new ArrayList%3C
-IAssert
+%3E();%0A    final Collection%3CIAssert%3E failures = new ArrayList%3C
 %3E();%0A    final S
@@ -603,309 +603,8 @@
   %7D%0A
-    %7D;%0A    sa.assertTrue(true);%0A    sa.assertTrue(false);%0A    Assert.assertEquals(succeed.size(), 1, succeed.toString());%0A  %7D%0A%0A  @Test%0A  public void testOnFailureCalled() throws Exception %7B%0A    final Collection%3CIAssert%3E failured = new ArrayList%3CIAssert%3E();%0A    final SoftAssert sa = new SoftAssert() %7B
 %0A   
@@ -709,17 +709,17 @@
  failure
-d
+s
 .add(ass
@@ -793,24 +793,88 @@
 rue(false);%0A
+    Assert.assertEquals(succeed.size(), 1, succeed.toString());%0A
     Assert.a
@@ -892,17 +892,17 @@
 (failure
-d
+s
 .size(),
@@ -912,17 +912,17 @@
  failure
-d
+s
 .toStrin

Rework after review