#60
[JUnit] Parametrized Test
Need Junit 4.11
@RunWith(Parameterized.class) public class ParametrizedTest { /** The Logger. */ private static final Logger LOGGER = LoggerFactory.getLogger(ParametrizedTest.class); /** XML Input Folder. */ private static File inputFolder = new File("target/classes/input"); /** XML Target Folder. */ private static File targetFolder = new File("target/test-classes/output"); private final File file; private final String param; /** * Default constructor. */ public ParametrizedTest(File file, String param) { this.file = file; this.param = param; } /** * Prepare env. for test run. * * @throws IOException */ public static void initClass() throws IOException { LOGGER.info("initClass()"); targetFolder.delete(); targetFolder.mkdirs(); } @Parameters(name = "{1}") public static Collection<Object[]> data() throws IOException { initClass(); return getAllFiles(); } /** * Test to run */ @Test public void test_1() { LOGGER.warn("------------------------------------------------------------------------"); LOGGER.warn("Processing : " + param); Assert.assertTrue(true); } /** * List files to process. * * @return List files to process. */ public static Collection<Object[]> getAllFiles() { LOGGER.info("Initialize collection"); List<Object[]> result = new ArrayList<Object[]>(); for (File template : targetFolder.listFiles()) { result.add(new Object[] { template, template.getName() }); } return result; } }
[JQuery] refresh page every X seconds [Maven] Copy file with SCP
One thought on “[JUnit] Parametrized Test”