Professional Documents
Culture Documents
Abstract—This report is integrated in the Software Quality JUnit is a unit testing framework for Java programming
subject, which consists in the realization of a work aimed at the language. It plays a crucial role test-driven development and
implementation of a technology or tool in the context of is a family of unit testing frameworks collectively known as
Software Quality. From the topics guided by the Professor, I will xUnit.
have as subject to develop "Explore the combination of the
Mockito framework with JUnit", where from this composition JUnit promotes the idea of "first testing then coding",
I'll discuss unit tests, JUnit as well as its main functions, I will which emphasizes on setting up the test data for a piece of
also deal with Test Driven Development, Data Builders, make a code that can be tested first and then implemented. This
brief analysis of the coverage of the code and later, I'll address approach is like "test a little, code a little, test a little, code a
the Mocks, in this assignment, we will see how to dominate and little." It increases the productivity of the programmer and the
how entities should behave to reflect the scenario we want to test stability of program code, which in turn reduces the stress on
and also how to check if the interactions classes with these the programmer and the time spent on debugging.
entities are working as expected.
Mocking is a way to test the functionality of a class in
Finally, I will introduce a tool similar to Mockito which is isolation. Mocking does not require a database connection or
Power Mockito. The latter being more powerful and a tool that properties file read or file server read to test a functionality.
requires greater care. With it, we'll see: How can we overcome Mock objects do the mocking of the real service. A mock
Mockito’s limitations and how the two tools can work together. object returns a dummy data corresponding to some dummy
input passed to it.
Keywords—unit test, Junit, Mockito, test driven Development,
Data Builders and power Mockito. II. UNIT TESTING
I. INTRODUCTION (HEADING 1) A. Unit Testing Techniques
The simplest and quickest initial way to automate the UNIT TESTING, also known as COMPONENT
testing of our code is precisely with the use of unit tests.Junit's TESTING, is a level of software testing where individual
approach, first goes through a knowledge about unitary units / components of a software are tested. The purpose is to
testing. UNIT TESTING is a type of software testing where validate that each unit of the software performs as designed.
individual units or components of a software are tested. The The Unit Testing Techniques are mainly categorized into three
purpose is to validate that each unit of the software code parts which are Black box testing that involves testing of user
performs as expected. Unit Testing is done during the interface along with input and output, White box testing that
development (coding phase) of an application by the involves testing the functional behaviour of the software
developers. Unit Tests isolate a section of code and verify its application and Gray box testing(combination of white-box
correctness. A unit may be an individual function, method, testing and black-box testing) that is used to execute test
procedure, module, or object. In SDLC, STLC, V Model, Unit suites, test methods, test cases and performing risk analysis.
testing is first level of testing done before integration testing. Code coverage techniques used in Unit Testing are listed
Unit testing is a Whitebox testing technique that is usually below:
performed by the developer. Though, in a practical world due
to time crunch or reluctance of developers to tests, QA • Statement Coverage
engineers also do unit testing.
• Decision Coverage
• Branch Coverage
Unit Testing is important because software developers
sometimes try saving time doing minimal unit testing and this • Condition Coverage
is myth because inappropriate unit testing leads to high cost • Finite State Machine Coverage
Defect fixing during System Testing, Integration Testing and
even Beta Testing after application is built. If proper unit B. Unit Testing Example: Mock Objects
testing is done in early development, then it saves time and Unit testing relies on mock objects being created to test
money in the end. sections of code that are not yet part of a complete application.
Here, are the key reasons to perform unit testing: Unit Mock objects fill in for the missing parts of the program.
testing -> Integration testing -> System testing -> Acceptance For example, you might have a function that needs
Testing. variables or objects that are not created yet. In unit testing,
those will be accounted for in the form of mock objects created
Execution Suite
Because our tests are in more than one class, it's interesting
We see that it has emitted a failures and bar turned to have a way to run them all in just a single test battery. For
this, I will create the suites package, where you will have the
red, this happens, when there is an error or failures and it is
execution suite. JUnit, recognize the execution class when we
only possible, thanks to the assertions of Junit. Making it easy
use the @RunWith (Suite.class)
to see errors and failures. If everything is compliant, the bar
will keep it green.
The failure was to have introduced a different day
than Monday.