Код: Выделить всё
public static void dummymethod(String file1, String file2) {
….
try (InputStream xsdStream = XMLValidator.class.getClassLoader().getResourceAsStream(file1)) {
// do something with file2
….
}
}….
}
Код: Выделить всё
public class MyLoginTest {
@Test
void testValidfie() {
String path1 = “file.json”;
String path2 = “file2.json”;
dummymethod(path1, path2);
assertTrue(true);
}
Вот структура программы:
Код: Выделить всё
my-project
├── src
│ ├── main
│ │ ├── java
│ │ │ └── package
│ │ │ └── Myclass.java // Contains dummymethod
│ │ └── resources
│ │ ├── file.json // Resource for production code
│ │ └── file2.json // Another resource for production code
│ └── test
│ ├── java
│ │ └── util
│ │ ├── MyLoginTest.java // Contains testValidFile
│ │ └── OtherTest.java // Additional tests if needed
│ └── resources
│ ├── file.json // Test resource
│ └── file2.json // Another test resource
Подробнее здесь: https://stackoverflow.com/questions/790 ... unit-tests