JUnit is a unit testing framework for the Java programming language. JUnit has been important in the development of test-driven development, and is one of a family of unit testing frameworks collectively known as xUnit that originated with JUnit.
This tutorial will teach you how to use JUnit in your day-2-day life of any project unit testing while working with Java programming language.
Audience
This tutorial has been prepared for the beginners to help them understand basic functionality of JUnit tool. After completing this tutorial you will find yourself at a moderate level of expertise in using JUnit testing framework from where you can take yourself to next levels.
Prerequisites
We assume you are going to use JUnit to handle all levels of Java projects development. So it will be good if you have knowledge of software development using any programming language specially Java programming and software testing process.
Testing is the process of checking the functionality of the application whether it is working as per requirements and to ensure that at developer level, unit testing comes into picture. Unit testing is the testing of single entity (class or method). Unit testing is very essential to every software company to give a quality product to their customers.
Unit testing can be done in two ways
Manual testing | Automated testing |
---|---|
Executing the test cases manually without any tool support is known as manual testing.
| Taking tool support and executing the test cases by using automation tool is known as automation testing.
|
What is JUnit ?
JUnit is a unit testing framework for the Java Programming Language. It is important in the test driven development, and is one of a family of unit testing frameworks collectively known as xUnit.
JUnit promotes the idea of "first testing then coding", which emphasis on setting up the test data for a piece of code which can be tested first and then can be implemented . This approach is like "test a little, code a little, test a little, code a little..." which increases programmer productivity and stability of program code that reduces programmer stress and the time spent on debugging.
Features
JUnit is an open source framework which is used for writing & running tests.
Provides Annotation to identify the test methods.
Provides Assertions for testing expected results.
Provides Test runners for running tests.
JUnit tests allow you to write code faster which increasing quality
JUnit is elegantly simple. It is less complex & takes less time.
JUnit tests can be run automatically and they check their own results and provide immediate feedback. There's no need to manually comb through a report of test results.
JUnit tests can be organized into test suites containing test cases and even other test suites.
Junit shows test progress in a bar that is green if test is going fine and it turns red when a test fails.
What is a Unit Test Case ?
A Unit Test Case is a part of code which ensures that the another part of code (method) works as expected. To achieve those desired results quickly, test framework is required .JUnit is perfect unit test framework for java programming language.
A formal written unit test case is characterized by a known input and by an expected output, which is worked out before the test is executed. The known input should test a precondition and the expected output should test a postcondition.
There must be at least two unit test cases for each requirement: one positive test and one negative test. If a requirement has sub-requirements, each sub-requirement must have at least two test cases as positive and negative.
|
|
|
|
No comments:
Post a Comment