Implementation of interface automation testing framework based on Junit!

Layered automated testing 5 to 10 years ago, the automated testing we came into contact with was more focused on automated testing of the UI layer. Mercury’s WinRunner/QTP was a typical representative of the commercial automated testing products of that era. At that time, everyone simply wanted to use a Automated tools replace human clicks, […]

SpringBoot integrates Junit5

1. Version Description SpringBoot 2.4 and above remove the default dependence on Vintage. If you need to be compatible with junit4, you need to introduce it yourself (you cannot use the function @Test of junit4) 2.Introduce junit5 dependency <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> After SpringBoot integrates Junit. Write test methods. @Test annotation (note that you […]

Software Quality and Testing Experiment 5: Unit Testing with Eclipse (IDEA) Junit

1. Experimental purposes and requirements 1.1 Use Junit environment configuration in Eclipse (or IDEA) environment 1.2 Design of Junit test script 1.3 Test results 2. Experimental environment window 10 IntelliJ IDEA 2023.1 x64 Java Junit 3. Experiment content Configure the Junit environment in the IDEA tool Design a Junit test example script about the triangle […]

Using Junit to unit test the BMI index

This test is a practical use of the Junit test platform. Junit is a unit testing framework for Java language. It was founded by Kent Beck and Erich Gamma and has gradually become the most successful one in the xUnit family derived from Kent Beck’s sUnit. Junit has its own extended ecosystem. Most Java development […]

JUnit5 dependency injection and testing interface!

Dependency Injection The previous JUnit class construction methods and test methods could not have parameters. JUnit Jupiter has a disruptive improvement, which is to allow them to have parameters, so that dependency injection can be done. If you are familiar with pytest fixtures, you will know how powerful this technology is. ParameterResolver is an interface […]

13.5 Junit5 (unit testing framework for Java)

1. Junit is a unit testing framework for Java 2. Notes 1.@Test: The current method is a test case. a. Go to the maven central warehouse to download dependencies (JUnit Jupiter API) <!– https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api –> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-api</artifactId> <version>5.9.1</version> <scope>test</scope> </dependency> b. The test method can be modified with public or not, but cannot be […]

JUnit5 dependency injection and testing interface!

Dependency Injection The previous JUnit class construction methods and test methods could not have parameters. JUnit Jupiter has a disruptive improvement, which is to allow them to have parameters, so that dependency injection can be done. If you are familiar with pytest fixtures, you will know how powerful this technology is. ParameterResolver is an interface […]

JUnit5 conditional testing, nested testing, repeated testing

Conditional test JUnit5 supports conditional annotations to determine whether to execute a test based on a Boolean value. Custom conditions The @EnabledIf and @DisabledIf annotations are used to set custom conditions, example: @Test @EnabledIf(“customCondition”) void enabled() { // … } @Test @DisabledIf(“customCondition”) void disabled() { // … } boolean customCondition() { return true; } The […]

Several ways to parameterize testing in JUnit5!

Parameterized testing has always been a hotly discussed topic. We all know that JMeter has four parameterization methods: user-defined variables, user parameters, CSV files, and function assistants. So what methods of parameterized testing does JUnit5 have? dependence JUnit5 needs to add the junit-jupiter-params dependency to use parameterization: <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-params</artifactId> <version>5.7.2</version> <scope>test</scope> </dependency> Simple example […]

JUnit5 conditional testing, nested testing, repeated testing

Conditional test JUnit5 supports conditional annotations to determine whether to execute a test based on a Boolean value. Custom conditions The @EnabledIf and @DisabledIf annotations are used to set custom conditions, example: @Test @EnabledIf(“customCondition”) void enabled() { // … } @Test @DisabledIf(“customCondition”) void disabled() { // … } boolean customCondition() { return true; } The […]