0

I have a test class as below in test->java->com.example->SampleIT.java

test-config.xml exists at the location mentioned below However, when I run mvn clean install or mvn test, the below test is not recognized hence not run I am not sure why

@ContextConfiguration(locations = {"classpath:META-INF/spring/test-config.xml"})
@RunWith(SpringJunit4ClassRunner.class)
public class SampleIT{
   @Autowried
   private ProductServiceImpl serviceImpl;
   
   @Test
   public void test() throws Exception{
      assertNotNull(serviceImpl)
   }

}

below are the dependencies in my pom

<dependencyManagement>
   <dependency>
       <groupId>org.springframework.batch</groupId>
       <artifactId>spring-batch-core></artifactId>
       <version>4.2.4-RELEASE</version>
   </dependency>
   <dependency>
       <groupId>org.springframework.batch</groupId>
       <artifactId>spring-batch-infrastructure></artifactId>
       <version>4.2.4-RELEASE</version>
   </dependency>
</dependencyManagement>

<dependencies>

<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-batch></artifactId>
<dependency>

<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter></artifactId>
<dependency>
<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-test></artifactId>
     <scope>test</scope>
<dependency>
</dependencies>

<build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
</build>
Neha
  • 11
  • 2
  • I'm not sure why you duplicated the question, but I've added an answer to the more recent [question](https://stackoverflow.com/questions/69686021/junit-test-works-only-when-renamed-test-class-name). – rieckpil Oct 27 '21 at 06:37

1 Answers1

0

It's not recognizable because you've spelled $ instead of 4 in @RunWith(SpringJunit$ClassRunner.class) at SimpleITclass

Malakai
  • 3,011
  • 9
  • 35
  • 49