I have tried many configurations. I try to invoke simple System.out as a test to check my configuration :
public class DaoTest {
@Test
public void commentTest() {
System.out.println("test working");
}}
My configuration classes use properties file to get the values and class that holds string constants values:
public static final String DATASOURCE_PATH = "dataSource.driver_class_name";
I annotated the test class with:
@RunWith(SpringJUnit4ClassRunner.class)
@PropertySource(
value={"classpath:spring.properties"},
ignoreResourceNotFound = true)
@ContextConfiguration(classes = { TestConfig.class, ConfigurationConstants.class, ApplicationConfigCore.class, HibernateConfig.class})
@WebAppConfiguration()
@ActiveProfiles(profiles = "test")
Where's TestConfig basically consists of classpath because I tried different ways yet still don't know where's my mistake. Also i added the spring.properties file both to the resources file of main as well as test package.
So the question I have is where's mistake and when we deploy web app in spring it takes resources from src/main/resources
folder, so what's the case with tests. Is it gonna be: src/test/resources
? In case of tests that takes the configuration, like my case, from main app configuration classes - do those classes will find right src/main/resources
folder or will they try to check for test/./properties file ?
BTW. when location of properties added to @ContextConfiguration
i got Cannot process locations AND classes for context configuration
exception
Aucun commentaire:
Enregistrer un commentaire