Soft : Test Fails for sure, but execution Do not Stops even any assertion condition fails.
SoftAssert s = new SoftAssert();
s.assertEquls(1,1);
s.assertEquls(2,1);
s.assertAll();
Hard: Test Fails & STOPS then and their where any assertion condition fails.
Assertion a = new Assertion();
a.assertEquls(1,1);
Showing posts with label testng. Show all posts
Showing posts with label testng. Show all posts
Monday, 17 September 2018
Testng - how to skip a test case at run time
@Test
public void m1(){
if(aboveMethodFailed)
throw new SkipException("Skipped");
}
using
throw new SkipException("Skipped"); statement we can skip an test case.
public void m1(){
if(aboveMethodFailed)
throw new SkipException("Skipped");
}
using
throw new SkipException("Skipped"); statement we can skip an test case.
Thursday, 16 August 2018
Report NG reports
Report NG report config is quite simple.
1. add dependencies
2. add listeners
3. Verify reports in test-output/HTML folder
As we are aware these ReportNG reports are beautiful than default TestNG reports
Maven dependenciets
<!-- https://mvnrepository.com/artifact/org.uncommons/reportng -->
<dependency>
<groupId>org.uncommons</groupId>
<artifactId>reportng</artifactId>
<version>1.1.4</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/velocity/velocity-dep -->
<dependency>
<groupId>velocity</groupId>
<artifactId>velocity-dep</artifactId>
<version>1.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.inject/guice -->
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>3.0</version>
</dependency>
Add listeners in testng.xml
<listeners>
<listener class-name="org.uncommons.reportng.HTMLReporter" />
<listener class-name="org.uncommons.reportng.JUnitXMLReporter" />
</listeners>
Wednesday, 11 January 2017
Soft assertions vs Hard assertions in TestNG
When hard assertion will fail Inside any test method, remaining execution of that specific test method will be aborted. Now If you wants to continue remaining test part execution even If assertion fails and also you wants to report assertion failure In testng result report then you can use testng soft assertion method.
syntax:
import org.testng.asserts.SoftAssert;
SoftAssert s_assert = new SoftAssert();
s_assert.assertEquals(actual, expected);
syntax:
import org.testng.asserts.SoftAssert;
SoftAssert s_assert = new SoftAssert();
s_assert.assertEquals(actual, expected);
Labels:
assert,
hard,
hard assertion,
soft,
soft assertion,
testng
Subscribe to:
Posts (Atom)