我正在进行单元测试,为此我需要从excel文件中读取。这些文件位于文件夹中:module/test/resource/click/T001.xlsx
测试类位于module/test/java/validation/readers/spreadsheets/PlanilhaReaderTest.java
目录中,而I类测试位于src/main/java/validation/readers/spreadsheets/PlanilhaReader.java
如何打开目录所在文件(../ test/resource)?
我的测试
@Test(expected = InternalServerErrorException.class)
public void testReadMetadados_invalidPlanilha_invalidFormat() throws Exception {
oknok.validacao.entities.Planilha planilha = new Planilha().setPath(String.valueOf(PlanilhaReader.class.getClass().getResource("/click/T001.xlsx")));
Log.info(this, "Path: " + planilha.getPath());
planilhaReader.readMetadados(planilha);
}
输出
路径:文件:/home/daniela.morais/Development/git/myProject/myModule/ target / test-classes / 点击/ T001.xlsx