TestNG Assertions | Soft assertion and Hard assertion in Selenium TestNG

Опубликовано: 15 Ноябрь 2022
на канале: SDET Adda For QA Automation
1,658
20

Hard #assertion are used when you want to halt the execution of the test script (or test method) when the assert condition does not match with the expected result. #softassertion are used when the test script (or test method) need not be halted when the assertion condition does not meet the expected result. #testng #softassertion #hardassertion
Here is the sample TestNG class for your reference-

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

public class SoftAndHardAssertions {
@Test(priority=1)
public void softAssertion() {
SoftAssert softassert = new SoftAssert();
softassert.assertEquals(false, true);
System.out.println("Soft assertion"); // This statment will be executed
softassert.assertAll();
}
@Test(priority=2)
public void hardAssertion() {
Assert.assertEquals(false, true);
System.out.println("Hard assertion"); //This statment will not be executed
}
}

Following points are covered in this video-
What are the different Assertions in TestNG?
How to Use Soft Asserts in TestNG
How to Use Hard Asserts in TestNG
Difference between Soft and hard assert in TestNG.

Keep learning and thanks for watching 👍🙏


Смотрите видео TestNG Assertions | Soft assertion and Hard assertion in Selenium TestNG онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь SDET Adda For QA Automation 15 Ноябрь 2022, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 1,658 раз и оно понравилось 20 людям.