how to run this test: @SpringBootTest class ProductRepositoryTest { //@Autowired…
Jump to turn (12)
- 1how to run this test: @SpringBootTest class ProductRepositoryTest { //@Autowired
- 2Note: The ProductRepositoryTest class shown here is missing the @Repository anno
- 3anyways i am askinghow to ru the test
- 4got this error: org.junit.jupiter.api.extension.ParameterResolutionException: No
- 5but i dont want to use autowired
- 6i dont undestand the problem i already created product repository and initiatd i
- 7this is my produt repository public interface ProductRepository extends Couchbas
- 8i did everythingt please resolve rhe error. org.junit.jupiter.api.extension.Para
- 9Verify that your test class is in the same package or a subpackage of your main
- 10sam error: org.junit.jupiter.api.extension.ParameterResolutionException: No Para
- 11test failed: java.lang.IllegalStateException: Failed to load ApplicationContext
- 12it says: The bean 'productRepository', defined in com.sense.productcatalog.repos
- User
how to run this test: @SpringBootTest class ProductRepositoryTest {
code//@Autowired //private ProductRepository productRepository; private ProductRepository productRepository; public ProductRepositoryTest(ProductRepository productRepository) { this.productRepository = productRepository; } @Test void testProductMapping() { Product product = new Product(); product.setName("Product 1"); product.setDescription("Description for Product 1"); product.setPrice(BigDecimal.valueOf(9.99)); Product savedProduct = productRepository.save(product); //Verify Attributes assertThat(savedProduct).isNotNull(); assertThat(savedProduct.getName()).isEqualTo("Product 1"); assertThat(savedProduct.getDescription()).isEqualTo("Description for Product 1"); assertThat(savedProduct.getPrice()).isEqualTo(9.99); }}