Issue
I want to use @JsonTest
to write tests on JSON serialization for my library. However, when I add the annotation to a test, I get:
Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with your test
As this is a library, I indeed don't have a main class annotated with @SpringBootConfiguration
. How can I avoid that I need to introduce this just to get the testing framework going?
Solution
Seems the only way is to actually add a dummy application. In my case, I added this into src/test/java
to avoid it will end up in the production sources. So something like this:
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* Just created this here to make @JsonTest work
*/
@SpringBootApplication
public class DummyApplication {
}
Answered By - Wim Deblauwe
Answer Checked By - David Goodson (JavaFixing Volunteer)