Part 13
58 : Tell me main features of JUnit.
Answer : JUnit features are as bellow.
- JUnit Is unit software testing framework. So It helps software developers to create and run unit test cases very easily.
- There are many different annotations available In JUnit. Using all those annotations, we can Identify and configure webdriver software test case very easily.
- JUnit supports many different assertions using which we can compare webdriver software automation test's expected and actual result.
- We can create test suite for multiple test cases to run all of them In one go using JUnit.
- We can generate webdriver test execution HTML reports using JUnit. VIEW EXAMPLE.
59 : What are different assertions supported by JUnit?
Answer : List of JUnit assertions as bellow.
- assertEquals
- assertFalse
- assertTrue
- assertNull
- assertNotNull
- assertSame
- assertNotSame
- assertArrayEquals
60 : How to create and run JUnit test suite for selenium WebDriver?
Answer : For creating JUnit software test suite, we have to create test cases class files and one separate test suite file. Then we can write syntax like bellow In test suite file to run test suite.
In above example, junittest1.class and junittest2.class are test case class names.
VIEW PRACTICAL EXAMPLE on how to create and run JUnit test suite with selenium WebDriver.
@RunWith(Suite.class)
@SuiteClasses({ junittest1.class, junittest2.class })
public class junittestsuite {
}
In above example, junittest1.class and junittest2.class are test case class names.
VIEW PRACTICAL EXAMPLE on how to create and run JUnit test suite with selenium WebDriver.
61 : For what purpose, assertTrue and assertFalse assertions are used?
Answer : In selenium webdriver software test automation, We need to assert Boolean conditions true and false. We can assert both these conditions using assertTrue and assertFalse JUnit assertions.
62 : Can you give me example of JUnit assertEquals assertion?
Answer : Example of JUnit assertEquals assertion Is as bellow. It assert that values of actTotal and expTotal are equal or not.
public void sumExample() {
int val1 = 10;
int val2 = 20;
int expTotal = 35;
int actTotal = 0;
actTotal = val1 + val2;
assertEquals(actTotal, expTotal);
}
No comments:
Post a Comment