I've a functional test using Junit which tests delivery of xml file to an end-point. XML file is sent by client, so I copied it to a test folder, read it from there in my test and do asserts. We have 10-20 such files with different data but same format, my architect wants me to copy all of them into same folder, loop through them in same test, just to make sure that they are delivered successfully. Note, I am not testing any data validations in this test just successful delivery.I am not sure if its a good idea to loop through multiple files in a single test in my case because if one fails rest will not be executed and also not convinced for writing 20 tests doing exactly same thing. Please advice
Is it okay to test multiple similar files in one functional test
java;unit testing;functional testing
How you should write this test is more a matter of style than anything else. Some say that each test method should have only a single assertion, because that makes the test very focused, and it's easy to quickly tell exactly what was wrong.This seems too extreme to me, so you could follow the guidance of your architect but make the error message in your assertion clear as to which file caused the test failure. Even better, to have all files tested even when one fails, don't use assertions on a per-file basis. Cache each file's result in the execution loop and if any failed, output the details and fail the test. For example:@Testpublic void testAllFiles() {    final Set<String> failures = new HashSet<>();    for (File file : getAllFiles()) {        final Boolean success = processFile(file); // or however you determine success/failure        if (!success) failures.add(file.getName());    }    if (!failures.isEmpty()) {        log.error(Failed file(s):);        for (String filename : failures) {            log.error(\t+filename);        }        fail();    }}