com.codacy.scoobydoo.web.SoftAssertionsWrapper Maven / Gradle / Ivy
package com.codacy.scoobydoo.web;
import com.codacy.scoobydoo.LoggingHelper;
import org.testng.asserts.SoftAssert;
public class SoftAssertionsWrapper extends SoftAssert {
private final SoftAssert softAssert;
// TODO: this method should be static / Utils class.
public SoftAssertionsWrapper() {
this.softAssert = new SoftAssert();
}
public SoftAssert getSoftAssert() {
return softAssert;
}
public void assertAll() {
try {
softAssert.assertAll();
} catch (AssertionError e) {
LoggingHelper.error("Error on soft assertion.", e);
throw e;
}
LoggingHelper.info("All the assertions were right.");
}
public void assertEqualsWithLogs(Object actualObject, Object expectedObject, String errorMessage, String loggingMessage) {
LoggingHelper.info(loggingMessage);
softAssert.assertEquals(actualObject, expectedObject, errorMessage);
}
public void assertTrueWithLogs(Boolean actualBoolean, String errorMessage, String loggingMessage) {
LoggingHelper.info(loggingMessage);
softAssert.assertTrue(actualBoolean, errorMessage);
}
}