[JAVA] Solved the problem that the test could not be executed from the command line with spring-boot-starter-test

Operating environment

java 1.8 Spring Boot 2.2.4 JUnit4

Project structure

 src
│   ├── main
│ │ └── Omitted
│   │
│   └── test
│       └── java
│           └── com
│               └── testTool
│                   ├── TestToolApplicationTests.java
│                   └── web
│                       ├── controller
│                       │   └── TestToolControllerTest.java
│                       └── service
│                           └── TestToolServiceTest.java

problem

[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  11.028 s
[INFO] Finished at: 2020-05-27T15:42:18+09:00
[INFO] ------------------------------------------------------------------------

solution

<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
            <!--Add from here-->
			<plugin> 
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-surefire-plugin</artifactId>
				<version>2.22.0</version>
				<dependencies>
					<dependency>
						<groupId>org.apache.maven.surefire</groupId>
						<artifactId>surefire-junit4</artifactId>
						<version>2.22.0</version>
					</dependency>
				</dependencies>
				<configuration>
					<includes>
						<include>**/*.java</include>
					</includes>
				</configuration>
			</plugin>
            <!--Add up to here-->
		</plugins>
</build>

result

[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 5, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  11.559 s
[INFO] Finished at: 2020-05-27T16:39:06+09:00
[INFO] ------------------------------------------------------------------------

reference

Recommended Posts

Solved the problem that the test could not be executed from the command line with spring-boot-starter-test
Solved the problem that apt-get update could not be executed on Ubuntu (Virtual Box) on Windows.
The story that the request parameter from the iPhone application could not be obtained successfully with the Servlet
About the problem that the server can not be started with rails s
The story that the forced update could not be implemented
The case that @Autowired could not be used in JUnit5
Problem that yarn install could not be done from npm repository created by Azure DevOps
How to solve the problem that you can not pull image from docker hub with Minikube
Solved the problem that the scroll event did not fire in JQuery
Note that Insert could not be done with Spring Data JDBC
The story of stopping because the rails test could not be done
Correspond to "error that basic authentication does not pass" in the test code "The story that could not be done"
The story that the Servlet could not be loaded in the Java Web application
After verifying the Monty Hall problem with Ruby, a story that I could understand well and did not understand well
About the case that ("b" .. "aa") could not be used in Ruby Range
[CentOS8] Since the javac command could not be used, install the java development environment.
Using JUnit from the command line on Ubuntu
Command that the registered information was not found
Solved the problem that profile and logout were not displayed on the screen after signup.
Notes on updating Ubuntu from the command line (16.04 → 18.04, 18.04 → 20.04 both)
[Java] Coverage report could not be created with the combination of default method of Cobertura + interface