#Why do I have to use @ContextConfiguration without a ContextConfiguration to load the AppContext?

1 messages · Page 1 of 1 (latest)

leaden cairnBOT
#

<@&1004656351647117403> please have a look, thanks.

leaden cairnBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

remote rapids
#

what if you try this setup

@ExtendWith(SpringExtension.class)
@SpringBootTest
@AutoConfigureMockMvc
public class AuthenticationControllerTest {

    @Autowired
    private MockMvc mockMvc;
    @MockBean
    //.. service ```
marsh grail
leaden cairnBOT
marsh grail
#

Update: Forgot to add the @ActiveProfiles("test") annotation for the config (application-test.properties). This is the config: ```

Datasource Settings

spring.datasource.url=jdbc:h2:mem:test;DB_CLOSE_DELAY=-1
spring.datasource.driver-class-name=org.h2.Driver

spring.datasource.username=sa

spring.datasource.password=sa

spring.jpa.database-platform=org.hibernate.dialect.H2Dialect

Hibernate Settings

spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.properties.hibernate.show_sql=true

Debug Settings

logging.level.org.springframework.jdbc.core.JdbcTemplate=DEBUG
logging.level.org.springframework.boot.autoconfigure=DEBUG

H2 Console Settings

spring.h2.console.enabled=true
spring.h2.console.path=/h2

Profile Settings

spring.config.activate.on-profile=test

leaden cairnBOT
leaden cairnBOT
remote rapids
#

Why is it trying to establish JDBC Connection and fails?

marsh grail
remote rapids
#

Can you see from logs that H2 is starting?

#

When starting test