Conteúdo do Curso
Java JUnit Library. Types of Testing
Java JUnit Library. Types of Testing
Types of Testing
Let's take a look at the main types and levels of testing. There are many types, but we will only discuss the fundamental ones that are important for you and that you will use.
Types
- Functional Testing:
This type of testing is a check to ensure that the program meets the expected result and performs all the functions it is supposed to.
Tools used for functional testing:
Selenium (for testing web applications), JUnit, TestNG.
Example of functional testing:
- Database Testing: As you've already understood, such a test verifies the correctness of working with and storing data in the database. For example, a test like this involves loading test data into the database before starting the application testing.
Note
We will discuss what databases are, how to use them in Java code, and how to connect them correctly in a separate course. For now, you can think of a database as a Collection from the data structures course.
- Performance Testing:
This type of testing assesses the performance level of a program. We won't delve into this type of testing in detail, but it's worth being aware of its existence. In brief, performance testing involves measuring system performance under specific load conditions.
Tools used: Apache JMeter, Gatling.
Levels
Testing levels are the layers of testing that will be employed when using one of the testing types. There are a total of 4 levels, one of which we will be studying in detail in this course: Unit Testing, Integration Testing, System Testing, and Acceptance Testing.
Let's take a closer look at unit and integration testing:
- Unit Testing:
This is the testing of individual program modules(units) for correct functionality. Such testing ensures that each module operates correctly in isolation from other modules. Unit testing is utilized in every programming language and is a minimum requirement for testing one's application.
Unit tests in Java are written using tools like JUnit and TestNG. However, we will use the JUnit library.
Example of a unit test:
Note
For now, there's no need to pay much attention to the syntax; we will delve into it further in this course. However, you can understand that this code is testing the
add()
method of theMathUtils
class.
- Integration Testing:
This level of testing verifies the functionality of interactions between individual units or components of the program. In other words, if other modules are used in one module, integration tests will check the functionality of such modules. This level of testing is related to unit testing but serves as a separate layer of testing.
Tools used for integration testing: JUnit, TestNG, Mockito.
Example of usage:
This chapter is introductory. In this course, we will exclusively focus on unit testing, while other levels and types of testing will be discussed only theoretically.
These are the primary types of testing used in Java. There are many other types of testing, such as Smoke testing, End-to-End testing, and so on, but these are not our current focus. Such testing is more in the realm of QA engineers. In this course, we will be covering two main testing methods: Unit Testing and Integration Testing. These are the tests that every junior developer should be able to write.
Obrigado pelo seu feedback!