Here is my build.gradle
file:
plugins {
id 'java'
id 'org.springframework.boot' version '3.0.4'
id 'io.spring.dependency-management' version '1.1.0'
}
group = 'com.kriegzeug'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '17'
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-mongodb'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.junit.vintage:junit-vintage-engine:5.8.2'
}
tasks.named('test') {
useJUnitPlatform()
}
Here is the simple test I'm trying to run. All I'm trying to do is determine that my code correctly converts a MongoDB document into my custom java object:
@RunWith(SpringRunner.class)
@SpringBootTest
public class DataModelTests {
@Autowired
CardRepository cardRepository;
@Test
public void SoloWithNoAttacks() {
// GIVEN
String cardName = "Mortitheurge Willbreaker";
// WHEN
Card card = cardRepository.findCardByName(cardName);
// THEN
Assertions.assertEquals("Mortitheurge Willbreaker", card.getName());
Assertions.assertEquals(3, card.getEdition());
Assertions.assertEquals("2021 v1", card.getRevision());
Assertions.assertEquals(List.of("Skorne", "Solo"), card.getKeywords());
}
}
And here is the error I'm getting when I try to run this test:
14:14:10.538 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Neither @ContextConfiguration nor @ContextHierarchy found for test class [DataModelTests]: using SpringBootContextLoader
14:14:10.542 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Could not detect default resource locations for test class [com.kriegzeug.college.DataModelTests]: no resource found for suffixes {-context.xml, Context.groovy}.
14:14:10.542 [main] INFO org.springframework.test.context.support.AnnotationConfigContextLoaderUtils - Could not detect default configuration classes for test class [com.kriegzeug.college.DataModelTests]: DataModelTests does not declare any static, non-private, non-final, nested classes annotated with @Configuration.
14:14:10.553 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Using ContextCustomizers for test class [DataModelTests]: [DisableObservabilityContextCustomizer, PropertyMappingContextCustomizer, Customizer, ExcludeFilterContextCustomizer, DuplicateJsonObjectContextCustomizer, MockitoContextCustomizer, TestRestTemplateContextCustomizer]
I've build SpringBoot test suites in the past without issue, this is a new project and the first time I've touched SprintBoot in a while. I'm just not understanding what I've done wrong in the setup.