luchob/softuni-music-db

Проблем с Integration tests

Closed this issue · 2 comments

br-ml commented

Здравей Лъчо,

Погледнах в нета, но не мога да се ориентирам, защо ми гърмят тестовете.
Изглежда свързано с cloudinary и явно иска някакво dependency ама ...
И двата ми теста в ReceiptControllerTest гърмят с една и съща грешка.
Ако можеш да ме насочиш, че отделих няколко часа вече в търсене.

https://github.com/br-ml/glutfree/tree/master

Вто какво дава като грешки :
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'glutfreeDBApplicationInit' defined in file [C:\Users\xxx\Desktop\Brani Personal\SoftUni\glutfreeWebSite\build\classes\java\main\eu\glutfree\glutfree\GlutfreeDBApplicationInit.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userServiceImpl' defined in file [C:\Users\xxx\Desktop\Brani Personal\SoftUni\glutfreeWebSite\build\classes\java\main\eu\glutfree\glutfree\service\impl\UserServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 2; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'applicationConfig': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'cloudinary.cloud-name' in value "${cloudinary.cloud-name}"

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userServiceImpl' defined in file [C:\Users\xxx\Desktop\Brani Personal\SoftUni\glutfreeWebSite\build\classes\java\main\eu\glutfree\glutfree\service\impl\UserServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 2; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'applicationConfig': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'cloudinary.cloud-name' in value "${cloudinary.cloud-name}"

Поздрави

Брани

Привет!

Тъй като вдигаш целия контекст на Спринг, в тестовия application.yml трябва да са налични всички пропъртита, които имаш в нормалния application.yml. В /src/test/resources/application.yml трябва да имаш тестови пропъртита за клаудинари, например:

cloudinary:
  cloud-name: test
  api-key: test
  api-secret: test

Иначе спринг не може да задоволи всички dependencies, например тези на клаудирани сървиса ти. Въпреки, че са test,test,test контекста ще може да се вдигне и съответния бийн да се инициализира. По късно ако искаш да тестваш нещо, което вика клаудинари сървиса може да използваш @MockBean анотация.

Поздрави,
Л.

br-ml commented

Супер, мерси !
Така мина :)