Я новичок в тестировании, и теперь у меня есть проблема, которую я не могу преодолеть.
@SpringBootTest
ExampleMakerSpec extends Specification {
@Autowired @Subject ExampleMaker exampleMaker
@Autowired
ExampleRepository exampleRepository
def EXAMPLE_VARIABLE = "Example"
@Transactional
def "example() trying to do somehthing" () {
when: "trying to make some examples"
Examples examples = exampleMaker.createExamples(examples)
then: "get examples sizes and saves them to database"
examples.size == 7
Мой мастер создания примеров выглядит так:
@Component
public class ExampleMaker {
@Autowired
ExampleRepository exampleRepository;
public void createExamples() {
exampleRepository.save(Examples);
}
}
И хранилище CRUD:
@Repository
public interface exampleRepository extends CrudRepository<Example, Long> {
}
но я всегда получаю
java.lang.NullPointerException в строке exampleRepository.save (Примеры).
Так что по какой-то причине тесты не могут найти хранилище.Мне нужна помощь, чтобы понять, чего не хватает.