Podcast
Questions and Answers
What is the primary purpose of testing?
What is the primary purpose of testing?
What is the benefit of Automated Testing?
What is the benefit of Automated Testing?
What is the purpose of Unit Testing?
What is the purpose of Unit Testing?
What is JUnit5?
What is JUnit5?
Signup and view all the answers
What is the purpose of Test Discovery?
What is the purpose of Test Discovery?
Signup and view all the answers
What is Code Coverage?
What is Code Coverage?
Signup and view all the answers
What is the purpose of @BeforeEach annotation?
What is the purpose of @BeforeEach annotation?
Signup and view all the answers
What is the purpose of Mocking Tests?
What is the purpose of Mocking Tests?
Signup and view all the answers
What is the purpose of JaCoCo?
What is the purpose of JaCoCo?
Signup and view all the answers
What is mocking in the context of testing?
What is mocking in the context of testing?
Signup and view all the answers
What is a stub in the context of mocking?
What is a stub in the context of mocking?
Signup and view all the answers
What is the main goal of CI/CD?
What is the main goal of CI/CD?
Signup and view all the answers
What is the main benefit of CI/CD?
What is the main benefit of CI/CD?
Signup and view all the answers
What is the first step in the TDD process?
What is the first step in the TDD process?
Signup and view all the answers
What is a spy in the context of mocking?
What is a spy in the context of mocking?
Signup and view all the answers
What is the command to generate a JaCoCo report?
What is the command to generate a JaCoCo report?
Signup and view all the answers
Study Notes
Testing
- Testing is the process of evaluating a system or its component(s) to find whether it satisfies the specified requirements or not.
- It involves the execution of a system or application to identify any gaps, errors, or missing requirements in the software.
Levels of Testing
- No specific information provided
Unit Testing
- Unit Testing is a software testing technique where individual units or components of a software application are tested in isolation from the rest of the application.
- It provides benefits such as automated testing, early detection of bugs, documentation, code refactoring, collaboration, and regression testing.
JUnit5
- JUnit5 is an API to write tests, mainly for use by developers.
- It provides a mechanism for discovering and running tests, and an API to allow easy interaction with IDEs and tools.
- JUnit5 consists of JUnit Platform, JUnit Jupiter, and JUnit Vintage.
- It offers benefits such as annotations and extensions, parameterized tests, backward compatibility, improved assertions API, and improved IDE support.
Test Discovery
- Test classes should follow the JUnit 5 naming conventions, ending with "Tests" or "TestCase".
- Test methods should be annotated with @Test or @ParameterizedTest.
- Test classes and methods are not required to be public, but they must not be private.
JUnit Annotations
- @BeforeEach: before each test
- @AfterEach: after each test
- @BeforeAll: before all tests
- @AfterAll: after all tests
- @Test: denotes a test method
- @Tag: used to filter tests
- @DisplayName: sets a custom display name for a test
- @Disabled: disables a test
- @Enabled: enables a test
- @TestFactory: defines a test factory
- @ParameterizedTest: runs a test with different parameters
- @RepeatedTest: runs a test repeatedly
Code Coverage using Jacoco
- Code coverage is a software metric used to measure how many lines of our code are executed during automated tests.
- Add the jacoco plugin in your pom.xml file to use JaCoCo.
- JaCoCo offers a simple way of declaring minimum requirements that should be met, otherwise the build will fail.
- Run $ mvn clean test jacoco:report to see the coverage report.
Mocking using Mockito
- Mocking is a technique used in testing to create objects that simulate the behavior of real objects.
- It helps isolate the code being tested by replacing real dependencies with objects that can be controlled.
- Stubs: objects that provide predefined responses to method calls.
- Spies: objects that record the interactions with the real objects they are spying on.
- Double: a general term for any object used as a substitute for a real object during testing.
Test Driven Development
- Test-Driven Development (TDD) is a software development approach where tests are written before the actual code.
- The development process in TDD follows these basic steps:
- Write a failing test that describes a piece of desired functionality.
- Write the minimum amount of code needed to make the test pass.
- Refactor the code to make it clean, improving its design without changing its behavior.
- Repeat the process.
CI/CD (Continuous Integration/Continuous Deployment)
- CI/CD is a set of best practices and a software development approach that aims to enhance the efficiency, quality, and speed of software development.
- It involves the automated integration of code changes, testing, and the continuous deployment of applications.
- Benefits of CI/CD include:
- Faster Delivery
- Higher Quality
- Consistency
- Collaboration
- Feedback Loop
- Tools for CI/CD include GitHub Actions, Jenkins, TeamCity, CircleCI, and GitLab CI/CD.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Description
This quiz covers the basics of testing, including levels of testing, unit testing, JUnit5, test discovery, and more. It also introduces test-driven development and continuous integration with GitHub Actions.