Make sure you are using unlogged-sdk version 0.1.15
<dependency>
<groupId>video.bug</groupId>
<artifactId>unlogged-sdk</artifactId>
<version>0.1.15</version>
</dependency>implementation group: 'video.bug', name: 'unlogged-sdk', version: '0.1.15'unlogged-sdk test runner uses the JUnit Platform test runner to run tests created using the unlogged plugin. To execute unlogged tests as mvn test/gradle test/intellij run test.
Start by creating the following test class file UnloggedTest.java in your src/test/java directory
import io.unlogged.runner.UnloggedTestRunner;
import org.junit.runner.RunWith;
@RunWith(UnloggedTestRunner.class)
public class UnloggedRunnerWithoutSpringTest {
}Yes this class has no methods as the tests will be based on src/test/resources/unlogged/<ClassName>.json files.
Now you can execute mvn test or gradle test to execute the tests from CLI.
For Springboot applications customize the above test as follows
@RunWith(UnloggedTestRunner.class)
@ComponentScan("<spring.application.package.name>") // update the package name here
@EnableAutoConfiguration
@PropertySource(
value = {"config/application.yml", "config/application-dev.yml"}, // update the config files you want to use
factory = UnloggedRunnerTest.YamlPropertySourceFactory.class) // this is for supporting yml files
@EnableConfigurationProperties({ApplicationProperties.class}) // specify your test application properties
@TestConfiguration
public class UnloggedRunnerTest {
public static class YamlPropertySourceFactory implements PropertySourceFactory {
public YamlPropertySourceFactory() {
}
@Override
public PropertiesPropertySource createPropertySource(String name, EncodedResource encodedResource) throws IOException {
YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean();
factory.setResources(encodedResource.getResource());
return new PropertiesPropertySource(encodedResource.getResource().getFilename(), factory.getObject());
}
}
}With this, unlogged test runner will create as instance of the spring application context and execute the tests based on the beans created by spring.