All Downloads are FREE. Search and download functionalities are using the official Maven repository.

automated.assertions.StringAssertion Maven / Gradle / Ivy

The newest version!
package automated.assertions;

import automated.test_manage.run.TestCaseFiles;
import org.testng.Assert;
import automated.reporting.TestReporter;

/**
 * Created by Ismail on 12/25/2017.
 * This class contains Assertions related to Strings only
 */
public class StringAssertion {

    /*************** Class Methods Section ***************/
    // This method compare two strings if equals and fails if not equal
    // If this method fail then test case will fail
    public static void verifyTwoStrings(String actual, String expected, String errMessage) {
        // Verify if errMessage Provided from TestCase File
        // Then will read errMessage property with getTestCaseProperty method
        // from TestCaseFiles class and return provided string from the file
        if (!TestCaseFiles.getTestCaseProperty(errMessage).isEmpty())
            errMessage = TestCaseFiles.getTestCaseProperty(errMessage);

        try {// Assert if two strings are equal then pass
            Assert.assertEquals(actual, expected, errMessage);
        } catch (Throwable throwable) {
            // If assert fails then will throw an error and catch
            // that error to report it as step fails
            TestReporter.fail(throwable.getMessage(), true);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy