Pregunta

I have a project as following:

Project
    Project-A/
        src/test/java/
            someTests.java
        src/test/resources
            database/
                create.sql
                insert.sql
            spring/
                test-config.xml
    project-B/
        src/test/java
            otherTests.java

pom.xml of Project-B:

<dependency>
    <groupId>${project.groupId}</groupId>
    <artifactId>Project-A</artifactId>
</dependency>

And in someTests.java, my configuration is:

@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@ContextConfiguration(locations = { "file:src/main/webapp/WEB-INF/spring/webapp-config.xml", "classpath:spring/test-dao-config.xml" })
public class DacsDAOImplTest

I want to reuse test-config.xml, create.sql and insert.sql in otherTests.java.

I have already tried in otherTests.java

@ContextConfiguration(locations = {"classpath*:spring/test-dao-config.xml"})

But this doesn't seem to work...

Edit: Geoand's answer help, I have no more exception related to beans, but now I have a

FileNotFoundException: class path resource [exception-messages.properties] cannot be opened because it does not exist.

Since I don't understand exactly what changes have done, I don't know how to fix this... exception-messages are used in webapp-config.xml as <context:property-placeholder location="classpath:exception-messages.properties" />

¿Fue útil?

Solución

I think the problem is that although you are importing Project-A into Project-B, the of test code does not get included by Maven. Check out the solutions in this SO question to see if it helps at all

EDIT:

Once you get maven to be to import the test code as well, you will need to create .properties files under /test/resources that contain the test values of the properties you are using in the application

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top