Spring Boot Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.1:test

failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.20:test (default-test)
maven-surefire-plugin failed
maven-surefire-plugin test failed: there was an error in the forked process
maven-surefire-plugin:2.22.2:test failed
caused by: org.apache.maven.plugin.mojofailureexception: no tests were executed!
org.apache.maven.lifecycle.lifecycleexecutionexception: failed to execute goal
failure to transfer org/apache/maven/plugins/maven-surefire-plugin:pom:2.12 4
a required class is missing: org/apache/maven/plugin/surefire/surefirereportparameters

I am using Eclipse Version: 2018-09 (4.9.0) and i have installed the Spring Tool Suit(STS) in eclipse for building Spring Boot Applications.

Question-> When ever I create new Spring Starter Project and try to maven build my project without any code addition. Build fails with below Error.

[WARNING] The requested profile "pom.xml" could not be activated because it does not exist.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.1:test (default-test) on project DemoSpringProject: There are test failures.
[ERROR] 
[ERROR] Please refer to C:\Users\SP064774\Util-Workspace\DemoSpringProject\target\surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

If I remove the test folder which is having the default test. it work fine. But why this happens. Below folder is the one i deleted which generated by Spring boot project

src/test/java

Thanks in advance.

Update

Below is the default test file which get generated.

@RunWith(SpringRunner.class)
@SpringBootTest
public class DemoSpringProjectApplicationTests {

  @Test
  public void contextLoads() {
  }

}

Log from the refered file. C:\Users\SP064774\Util-Workspace\DemoSpringProject\target\surefire-reports

--------------------------------------------------------------------
Test set: com.example.demo.DemoSpringProjectApplicationTests
-------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 3.473 s 

FAILURE! - in com.example.demo.DemoSpringProjectApplicationTests
contextLoads(com.example.demo.DemoSpringProjectApplicationTests)  Time 
elapsed: 0.002 s  <<< ERROR!
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: 
org.springframework.beans.factory.UnsatisfiedDependencyException: 
Error creating bean with name 

'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/ DataSourceConfiguration$Hikari .class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$ DataSourceBeanCreationException: Failed to determine a suitable driver class Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$ Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$ DataSourceBeanCreationException: Failed to determine a suitable driver class Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method ' dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$ DataSourceBeanCreationException: Failed to determine a suitable driver class Caused by: org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$ DataSourceBeanCreationException: Failed to determine a suitable driver class

POM.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.1.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>DemoSpringProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>DemoSpringProject</name>
<description>Demo project for Spring Boot</description>

<properties>
    <java.version>1.8</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-integration</artifactId>
    </dependency>

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

You haven't shared your pom.xml file so I cannot be certain, but it looks like you don't have a database driver on the classpath. You'll either need to add a dependency on an embedded database (H2 or HSQLDB) or setup up a separate database such as MySQL or Postgres and add the appropriate driver as a dependency.

Getting Failed to execute goal org.apache.maven.plugins:maven , Create any form of jhipster project with maven and run tests. This is a temporary fix until the surefire team have fixed this in a new version (after 2.22.1). @tibistibi resolve: Failed to execute goal maven-surefire #8693 #8714. Merged​. 0 of 1 task Sufire maven plugin is updated in spring-boot 2.1 branch. 36 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.1:test (default-test) on project sharp-common: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.22.1:test failed: Plugin org.apache.maven.plugins:maven-surefire-plugin:2.22.1 or one of its dependencies could not be resolved

In eclipse go to Windows->Preferences->Java->Installed JREs and change path to jdk home folder

Spring Boot Failed to execute goal org.apache.maven.plugins , Getting Failed to execute goal Any test case with Assertion failure. the latest released versions of TestNG (7.0.0-beta1) and surefire plugin (2.22.1) Updating maven-surefire-plugin version apache/incubator-pinot#4732. Overview of the issue After the latest java upgrade on at least debain and ubuntu maven surefire plugin stops working with this error: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.0:test (default-tes

Updating the jar plugin to 3.1.1 immediately fixes the problem:

<properties>
  <maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
</properties>

https://github.com/spring-projects/spring-boot/issues/16846#issuecomment-492792506

Maven Surefire Plugin – Dependency Information, org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M4:test allows late replacement of properties when the plugin is executed, Failed first will run tests that failed on previous run first, as well as new tests for this run. The temporary-​surefire-boot directory is project.build.directory on most platforms  Getting Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.20.1:test (default-test) on project TestSetup: There are test failures. #1693 Navsony opened this issue Feb 9, 2018 · 12 comments

Maven Surefire Plugin – surefire:test, ForkedProcessEvent class was missing while executing org.apache.maven.​plugins:maven-surefire-plugin (default-test) on project idgenerator: Execution default-test of goal failed: A required class was missing while executing /org/​apache/maven/surefire/surefire-junit4/2.22.1/surefire-junit4-2.22.1.jar  Relative path to temporary-surefire-boot directory containing internal Surefire temporary files. The temporary-surefire-boot directory is project.build.directory on most platforms or system default temporary-directory specified by the system property java.io.tmpdir on Windows (see SUREFIRE-1400). It is deleted after the test set has completed.

[#SUREFIRE-1732] ForkedProcessEvent class was , Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.1:​test (default-test) on project sharp-common: Execution  When creating JPA starter with Spring Initializr there is no dependency for embedded DB Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22

Spring boot application build failed due to test failure, Hi, Build of my Spring boot application is failing and showing below in logs: [​ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-​plugin:2.22.1:test (default-test) on project demo: There are test failures.

Comments
  • What does default test contain?
  • Updated the default Test
  • The warning about a profile named pom.xml not existing would suggest that there’s a mistake in the command you are using to launch Maven. What command are you using? Also, what do the files mentioned in the error message contain?
  • @Andy I am using clean install. And the file for with it is throwing this error is the one i have added in Update. Its auto generated Test class by spring boot. I have not added a single line of code
  • Ok, but what is the complete command you are using to run Maven? And it would still be useful to see the contents of the files mentioned in the error message that it suggests you refer to
  • I have updated the pom. and yes H2 dependency was not there i tried mvn - clean install after but still the same issue.
  • While doing some research i got this link Git link. But i was not able to understand properly.. github.com/jhipster/generator-jhipster/issues/8693
  • The problem discussed in that issue is specific to Debian-based Linux. You're using Windows so it is not relevant