I'm doing unit testing and for that I need to read from excel files. The files are located in the folder: module/test/resource/click/T001.xlsx
The test class is in the directory module/test/java/validation/readers/spreadsheets/PlanilhaReaderTest.java
and the class I test in src/main/java/validation/readers/spreadsheets/PlanilhaReader.java
How do I open the directory where it is located my files ( ../test/resource )?
My test
@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);
}
Output
Path: file:/home/daniela.morais/Development/git/myProject/myModule/target/test-classes/click/T001.xlsx