I have an instance where I have several hundred iterations I need to run of the same @Test using a @RunWith(Parameterized.class). Each takes about 10 minutes, so this overall test takes most of the day.
The problem is, the system we are running it against only has keeps logs for about 30 minutes, so if an iteration fails in the middle of the test we do not really have anything other than the stack trace that java gives for the failure, and which gives very little information about the state of the system that we are testing.
I tried adding a rule to the test like this:
...
@Rule
public TestWatcher logPuller = new TestWatcher() {
@Override
protected void failed(final Throwable e, final Description description)
{
downloadLogs(description);
}
};
...
@Parameters()
public static Collection<Object[]> generateData() {
return Arrays.asList(new Object[][] {.....}
...
@Test
public void runTest(){...}
But this only pulls the logs at the end of all of the iterations, rather than at the end of each failed iteration, and with the failure being long gone from the logs that are pulled, so the log shows no signs of what was happening at the time.
Is there a way of accomplishing this and keeping my parameterized input intact?