Beispiel #1
0
        public void Test_all_xml_files_in_test_graphs_directory()
        {
            // the advantage with iterating xml files is this method is that you do not have to add a new test method
            // for each new xml file with test cases, but the disadvantage is that you do not automatically see which file failed
            // but that problem is handled in the loop below with a try/catch/throw

            int counterForNumberOfXmlFilesTested = 0;

            foreach (string pathToResourcesFoldersWithXmlTestFiles in pathsToResourcesFoldersWithXmlTestFiles)
            {
                IList <string> fileNames = resourceReader.GetNameOfFilesInResourcesFolder(pathToResourcesFoldersWithXmlTestFiles);
                foreach (string fileName in fileNames)
                {
                    if (fileName.ToLower().EndsWith(".xml") && !ShouldBeExcludedInFrequentTesting(fileName))
                    {
                        try {
                            runTestCaseDefinedInXmlFile(pathToResourcesFoldersWithXmlTestFiles, fileName, pathFinderFactoriesForAllImplementations);
                            counterForNumberOfXmlFilesTested++;
                        }
                        catch (Exception e) {
                            // Without try/catch here we would fail without seeing which test file caused the failure
                            // We might use the method 'Assert.fail' here but then we do not see the stack trace, so therefore throw exception here
                            throw new Exception("Failure for the test defined in file " + fileName + " , " + e.Message, e);
                        }
                    }
                }
            }
            Assert.That(counterForNumberOfXmlFilesTested >= minimumTotalNumberOfXmlTestFiles, "Too few files tested");         // TODO java hamcrest Assert.That(counterForNumberOfXmlFilesTested, greaterThanOrEqualTo(minimumTotalNumberOfXmlTestFiles));
        }