#Why do I have to use @ContextConfiguration without a ContextConfiguration to load the AppContext?
1 messages · Page 1 of 1 (latest)
While you are waiting for getting help, here are some tips to improve your experience:
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.
what if you try this setup
@ExtendWith(SpringExtension.class)
@SpringBootTest
@AutoConfigureMockMvc
public class AuthenticationControllerTest {
@Autowired
private MockMvc mockMvc;
@MockBean
//.. service ```
This also "doesn't work" (AppContext fails to load) but at least it fails while trying to establish the connection to the server (yes I have a valid config which I used for testing the repositories)
I uploaded your attachments as Gist.
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
Detected code, here are some useful tools:
I uploaded your attachments as Gist.
Why is it trying to establish JDBC Connection and fails?
I don't know, I thought @SpringBootTest is running a test with the whole ApplicationContext and an internal db