/** Invoked after the test class is instantiated and before any configuration method is called. */ public void onStart(ITestContext context) { String currentTestClassName = context.getCurrentXmlTest().getClasses().get(0).getName(); log.info("Before executing the test class :" + currentTestClassName); if (currentTestClassName != null) { try { artifactManager = ArtifactManager.getInstance(); artifactManager.deployArtifacts(context.getCurrentXmlTest().getClasses().get(0).getName()); } catch (Exception e) { log.error("Artifact Deployment Error ", e); CustomTestNgReportSetter reportSetter = new CustomTestNgReportSetter(); reportSetter.createReport(context, e); } } }
/** Invoked after all the tests have run and all their Configuration methods have been called. */ public void onFinish(ITestContext context) { try { assert artifactManager != null : "Artifact Manger is null"; artifactManager.cleanArtifacts(context.getCurrentXmlTest().getClasses().get(0).getName()); } catch (UnknownArtifactTypeException e) { /*cannot throw the exception */ log.error("Unknown Artifact type to be cleared ", e); CustomTestNgReportSetter reportSetter = new CustomTestNgReportSetter(); reportSetter.createReport(context, e); } catch (Exception e) { log.error("Artifact Cleaning Error ", e); CustomTestNgReportSetter reportSetter = new CustomTestNgReportSetter(); reportSetter.createReport(context, e); } }
@NotNull @Override public List<DeploymentSource> createArtifactDeploymentSources( Project project, ArtifactType... artifactTypes) { if (project.isDefault()) return Collections.emptyList(); Artifact[] artifacts = ArtifactManager.getInstance(project).getArtifacts(); List<Artifact> supportedArtifacts = new ArrayList<>(); Set<ArtifactType> typeSet = ContainerUtil.set(artifactTypes); for (Artifact artifact : artifacts) { if (typeSet.contains(artifact.getArtifactType())) { supportedArtifacts.add(artifact); } } return createArtifactDeploymentSources(project, supportedArtifacts); }