-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssertion2.java
More file actions
38 lines (29 loc) · 1.13 KB
/
Assertion2.java
File metadata and controls
38 lines (29 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package selenium;
import org.testng.Assert;
import org.testng.annotations.Test;
public class Assertion2 {
@Test
public void testCase2() {
//variable declaration of integer
int a = 10;
int b = 20;
String actualMessage = "Google";
String expectedMessage = "Google";
Assert.assertEquals(actualMessage, expectedMessage, "Actual and Expected are not matching.");
//here we use Assert.assertEquals(String actual, String expected, String message);
System.out.println("Assertion Pass");
Assert.assertFalse(a > b, "assertFalse condition get failed");
//here we use Assert.assertFalse(boolean condition, string message);
System.out.println("Balle Balle");
Assert.assertTrue(a > b, "Test Case will fail as b is greater");
// As assertion fails, execution will stop here
// Further line of code will not execute for same method
System.out.println("We are checking assertion");
}
@Test
public void testCase3() {
// Assertion are written in testCase2() method
// Hence the scope of assertion will be limited to testCase2() method only.
System.out.println("Hello Assertion");
}
}