I use gradle to build and test my application. I use the command
gradle test
But testing, which works great on startup due to eclipse, fails on startup using gradle. My test is defined below, and the properties file that it cannot find is in both of these folders:
/ home / user / Development / git / MyProject / SRC / home / Java / COM / MyCompany / configuration / Home / user / Development / git / MyProject / SRC / test / resources
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(loader = AnnotationConfigContextLoader.class, classes = { ApplicationConfig.class })
public class WebImportTest {
@Resource
private Environment env;
@Autowired
private JestClient jestClient;
my java configuration looks like this:
@Configuration
@ComponentScan({ "com.mycompany" })
@PropertySource("classpath:/com/mycompany/config/myproject.properties")
@Import(PersistenceConfig.class)
public class ApplicationConfig {
@Resource
private Environment env;
I am not experienced enough to find out the reason for this.
:myproject is getting tests from [task ':test']
:compileJava
Note: /home/user/Development/git/myproject/src/main/java/com/mycompany/entities/generated/Keys.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
:processResources UP-TO-DATE
:classes
:instrument SKIPPED
:copyCoberturaDatafile SKIPPED
:compileTestJava
:processTestResources UP-TO-DATE
:testClasses
:test
com.mycompany.myProject.DBConnectionTest > initializationError FAILED
java.lang.Exception
com.mycompany.myProject.WebImportTest > testWebImport FAILED
java.lang.IllegalStateException
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException
Caused by: java.io.FileNotFoundException
Why is the properties file not found ?!
source
share