0

I have application that create Course and Instructor, for this application i write some test. But they does not work correctly. Few days ago, everything work correctly, but today not! So when i run my DataJpaTest, i have some problem

18:07:52.849 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Neither @ContextConfiguration nor @ContextHierarchy found for test class [CourseDaoTest]: using SpringBootContextLoader
18:07:52.854 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Could not detect default resource locations for test class [spring.dao.CourseDaoTest]: no resource found for suffixes {-context.xml, Context.groovy}.
18:07:52.876 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Using ContextCustomizers for test class [CourseDaoTest]: [ExcludeFilterContextCustomizer, DuplicateJsonObjectContextCustomizer, MockitoContextCustomizer, TestRestTemplateContextCustomizer, DisableObservabilityContextCustomizer, PropertyMappingContextCustomizer, Customizer, DynamicPropertiesContextCustomizer]
18:07:53.003 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Using TestExecutionListeners for test class [CourseDaoTest]: [ServletTestExecutionListener, DirtiesContextBeforeModesTestExecutionListener, ApplicationEventsTestExecutionListener, MockitoTestExecutionListener, DependencyInjectionTestExecutionListener, DirtiesContextTestExecutionListener, TransactionalTestExecutionListener, SqlScriptsTestExecutionListener, EventPublishingTestExecutionListener, ResetMocksTestExecutionListener, RestDocsTestExecutionListener, MockRestServiceServerResetTestExecutionListener, MockMvcPrintOnlyOnFailureTestExecutionListener, WebDriverTestExecutionListener, MockWebServiceServerTestExecutionListener]
18:07:53.004 [main] DEBUG org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener - Before test class: class [CourseDaoTest], class annotated with @DirtiesContext [false] with mode [null]
18:07:53.067 [main] DEBUG org.testcontainers.utility.TestcontainersConfiguration - Testcontainers configuration overrides will be loaded from file:/C:/Users/Java/.testcontainers.properties
18:07:53.073 [main] WARN org.testcontainers.utility.TestcontainersConfiguration - Attempted to read Testcontainers configuration file at file:/C:/Users/Java/.testcontainers.properties but the file was not found. Exception message: FileNotFoundException: C:\Users\Java\.testcontainers.properties (The system cannot find the file specified)
18:07:53.075 [main] DEBUG org.testcontainers.utility.TestcontainersConfiguration - Testcontainers configuration overrides will be loaded from file:/C:/Users/Java/git/CourseSystem/CourseSystem/target/test-classes/testcontainers.properties
18:07:53.077 [main] INFO org.testcontainers.utility.ImageNameSubstitutor - Image name substitution will be performed by: DefaultImageNameSubstitutor (composite of 'ConfigurationFileImageNameSubstitutor' and 'PrefixingImageNameSubstitutor')
18:07:53.094 [main] DEBUG org.testcontainers.dockerclient.DockerClientProviderStrategy - Trying out strategy: NpipeSocketClientProviderStrategy
18:07:53.094 [main] DEBUG org.testcontainers.dockerclient.DockerClientProviderStrategy - DOCKER_HOST socket file '//./pipe/docker_engine' does not exist
18:07:53.094 [main] DEBUG org.testcontainers.dockerclient.DockerClientProviderStrategy - strategy NpipeSocketClientProviderStrategy did not pass the test
18:07:53.097 [main] INFO org.testcontainers.dockerclient.DockerMachineClientProviderStrategy - docker-machine executable was not found on PATH ([C:/Users/Java/eclipseEE/eclipse//plugins/org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_19.0.1.v20221102-1007/jre/bin/server, C:/Users/Java/eclipseEE/eclipse//plugins/org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_19.0.1.v20221102-1007/jre/bin, C:\Program Files (x86)\Common Files\Oracle\Java\javapath, C:\Windows\System32, C:\Program Files\MySQL\MySQL Shell 8.0\bin\, C:\Users\Java\AppData\Local\GitHubDesktop\bin, C:\maven\tools\apache-maven-3.8.5\bin, C:\Program Files\Java\jdk1.8\bin, C:\Program Files\Git\cmd, C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR, C:\Program Files\Docker\Docker\resources\bin, C:\Program Files\MySQL\MySQL Shell 8.0\bin\, %USERPROFILE%\AppData\Local\Microsoft\WindowsApps, C:\Users\Java\AppData\Local\GitHubDesktop\bin, %M2%, C:Program Files\Java\jdk1.8\bin, C:\Program Files (x86)\KeyMan, C:\Users\Java\eclipseEE\eclipse])
18:07:53.098 [main] ERROR org.testcontainers.dockerclient.DockerClientProviderStrategy - Could not find a valid Docker environment. Please check configuration. Attempted configurations were:
As no valid configuration was found, execution cannot continue.
See https://www.testcontainers.org/on_failure.html for more details.
18:07:53.100 [main] DEBUG org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener - After test class: class [CourseDaoTest], class annotated

My Test

@DataJpaTest
@AutoConfigureTestDatabase (replace = AutoConfigureTestDatabase.Replace.NONE)
@Sql (scripts = {"C:\\Users\\Java\\eclipse-workspace\\CourseSystem\\db\\clear.sql", "C:\\Users\\Java\\eclipse-workspace\\CourseSystem\\db\\insert.sql   "})
class CourseDaoTest extends AbstractTest{
    
    @Autowired
    private CourseDao courseDao;
    
    @Test
    void findCoursesByCourseNameContains() {
        List <Course> courses = courseDao.findCourseBycourseName("Rubby");
        int expectedResult = 2;
        assertEquals(expectedResult, courses.size());
        
}
    
    @Test
    void getCoursesByStudentId () {
        List <Course> courses = courseDao.getCourseBystudentId(1L);
        int expectedResult = 1;
        assertEquals(expectedResult, courses);
        
    }
    
}

If somebody know where is problem, please say me , tnx!

Ken Chan
  • 84,777
  • 26
  • 143
  • 172
Jcoder
  • 27
  • 5

1 Answers1

0

Could not find a valid Docker environment. Please check configuration. Attempted configurations were: As no valid configuration was found, execution cannot continue.

The error message already gives you some hint. Together with your description that it worked several days ago but suddenly does not work now , I believe you forget to start the docker runtime environment when you run the test.

You can use docker info or the ways mentioned at here to check if docker really start. If not , start it and run the test again.

Ken Chan
  • 84,777
  • 26
  • 143
  • 172