Embedded GlassFish ignores Maven test resources

后端 未结 3 2090
無奈伤痛
無奈伤痛 2021-01-06 00:09

I have several session beans that I have written unit tests for. I have setup Maven to include a persistence.xml in the src/main/resources/META-INF directory that refers to

3条回答
  •  广开言路
    2021-01-06 00:37

    This answer might sounds silly but I was looking for a way which lets me run those tests from eclipse by Run As -> JUnit Test. This is how I made it:

    @BeforeClass
    public static void setUp() throws IOException {
        Files.copy(new File("target/test-classes/META-INF/persistence.xml"), new File("target/classes/META-INF/persistence.xml"));
        // ...
    }
    

    I'm just copying the test/persistence.xml to classes/persistence.xml. This works.

提交回复
热议问题