fongo

Adding configuration class to SpringBootTest breaks component scan

余生颓废 提交于 2019-12-02 13:38:13
问题 I am trying to disable real Mongo connection and replace it with Fongo mock in tests. Here is my test class: @SpringBootTest @RunWith(SpringRunner.class) public class ControllerTest { @Autowired private WebApplicationContext wac; @Autowired private ObjectMapper objectMapper; @MockBean private MyService service; private MockMvc mockMvc; @Before public void setup() { this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build(); } @Test public void performTest() throws Exception { ...

Junit/Fongo: How to make use of Fongo in the unit test for checking NotNull

六月ゝ 毕业季﹏ 提交于 2019-12-01 11:12:27
问题 I am writing a basic unit test that checks whether the returned query (type DataVersion) is not null. I have to make sure that I am using Fongo for testing my db. This is the repo class: @Repository public class DataVersionDaoMongo extends MongoBaseDao<DataVersion> implements DataVersionDao { @Autowired MongoOperations mongoOperations; public DataVersionDaoMongo() { initType(); } @Override public DataVersion findByDBAndCollection(String dbName, String collectionName) { Criteria criteria =