JUnit Framework

JUnit Framework is an open source framework designed by Kent Beck, Erich Gamma for the purpose of writing and running test cases for Java Programs. Junit is used to write and run repeatable automated unit tests so that we can be ensured that our code works as expected.

 

JUnit is used to test the web application without the server. This framework builds a relationship between development and testing process.

 

With the help of JUnit developer/tester design the Unit testing scripts. Unit testing scripts execute the piece of software and validate if that code results in the correct state or Invalid state.

JUnit can be easily integrated with the Eclipse IDE, ANT and Maven.(We will learn all of  these in coming tutorials)

 

Features of JUnit

JUnit contains many features, which support testing process. We are taking some important features if JUnit here-

1. Fixtures – Fixture is a fixed state of objects, which can be used as a baseline for running tests. A test fixture ensures that there is a fixed environment in which test cases can be run so that results are repeatable. We can use setUp() and tearDown() methods to setup the fixtures.

setUp() used to run before every test case and tearDown() after every test case Like you want to run every test in new browser instance so you can code browser invoke code in setUp() method and browser close code in tearDown() method.  @Beforetest and @Aftertest annotations support this functionality we will discuss this in details in coming tutorials.

 

2. Test SuiteTest suite is the bundle of Unit test cases. We use test Suite to club the test cases and run those from in the batch. In JUnit, @RunWith and @Suite annotation are used to run the suite test.

 

3. Test Runner – Test runner is used to running the cases.

 

We will discuss these all features with the example in coming tutorials. We will also see the use of JUnit with selenium web driver to automate the web project.

 

Selenium Tutorial:

If you liked this video, then please subscribe to our YouTube Channel for more video tutorials.

0 Comment

Leave a Reply