...26 public FailureRerunnerXml(Configuration configuration) {27 this.environmentVariables = configuration.getEnvironmentVariables();28 this.rerunFolderName = ThucydidesSystemProperty.RERUN_FAILURES_DIRECTORY.from(environmentVariables, DEFAULT_RERUN_FOLDER_NAME);29 try {30 jaxbContext = JAXBContext.newInstance(RerunnableClass.class);31 } catch (JAXBException e) {32 logger.error("cannot initialize jaxbContext",e);33 }34 }35 public void recordFailedTests(Map<String, List<String>> failedTests) {36 if(!RECORD_FAILURES.booleanFrom(environmentVariables, false))37 {38 return;39 }40 if(failedTests.size() == 0) {41 logger.info(" no failed tests to record" );42 return;43 }44 Path rerunFolder = Paths.get(rerunFolderName);45 if(!Files.exists(rerunFolder)) {46 try {47 Files.createDirectory(rerunFolder);48 }49 catch(FileAlreadyExistsException ex) {50 logger.error(" directory of rerun files already exists " );51 }52 catch (IOException e) {53 logger.error(" cannot create directory of rerun files " );54 return;55 }56 }57 try {58 RerunnableClass rerunnableClass = null;59 for(Map.Entry<String,List<String>> entry : failedTests.entrySet()) {60 String className = entry.getKey().replace("$", ".");61 Path rerunFile = Paths.get(rerunFolderName, className + "_rerun.xml");62 logger.info("recording failing tests in file " + rerunFile);63 if (Files.exists(rerunFile)) {64 Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();65 rerunnableClass = (RerunnableClass) jaxbUnmarshaller.unmarshal(rerunFile.toFile());66 }67 if (rerunnableClass == null) {68 rerunnableClass = new RerunnableClass();69 rerunnableClass.setClassName(className);70 }71 for (String failedTestMethodName : entry.getValue()) {72 logger.info("Adding failedTestMethodName " + failedTestMethodName);73 rerunnableClass.getMethodNames().add(failedTestMethodName);74 }75 Marshaller jaxbMarshaller = jaxbContext.createMarshaller();76 jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);77 jaxbMarshaller.marshal(rerunnableClass, rerunFile.toFile());78 }79 } catch(Throwable th) {80 logger.error("Error recording failing tests " + th.getMessage(), th);81 }82 }83 public boolean hasToRunTest(String className,String methodName) {84 if(!REPLAY_FAILURES.booleanFrom(environmentVariables, false))85 {86 return true;87 }88 logger.info("Check if must rerun method " + className + " " + methodName);89 try {90 Path rerunFile = Paths.get(rerunFolderName,className+ "_rerun.xml");91 if(Files.exists(rerunFile)) {92 Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();93 RerunnableClass rerunnableClass = (RerunnableClass) jaxbUnmarshaller.unmarshal(rerunFile.toFile());94 if(rerunnableClass.getClassName().equals(className) && rerunnableClass.getMethodNames().contains(methodName)) {95 logger.info("Found rerunnable method " + methodName);96 return true;97 }98 }99 } catch(Throwable th) {100 logger.error("Error when checking if method must be rerun: " + th.getMessage(), th);101 }102 return false;103 }104}...