How to use getBaseDir method of com.qaprosoft.carina.core.foundation.report.ReportContext class

Best Carina code snippet using com.qaprosoft.carina.core.foundation.report.ReportContext.getBaseDir

Source:AbstractTestListener.java Github

copy

Full Screen

...286 {287 String uuid = StringGenerator.generateNumeric(8);288 ParameterGenerator.setUUID(uuid);289290 ReportContext.getBaseDir(); // create directory for logging as soon as possible291292 /*293 * //dropbox client initialization if (!Configuration.get(Parameter.DROPBOX_ACCESS_TOKEN).isEmpty()) {294 * dropboxClient = new DropboxClient(Configuration.get(Parameter.DROPBOX_ACCESS_TOKEN)); }295 */296 super.onStart(context);297 }298299 @Override300 public void onTestStart(ITestResult result)301 {302 super.onTestStart(result);303304 if (!result.getTestContext().getCurrentXmlTest().getTestParameters() ...

Full Screen

Full Screen

Source:ReportContext.java Github

copy

Full Screen

...56 * directory. Directory is specific for any new test suite launch.57 * 58 * @return root screenshot folder for test launch.59 */60 public static synchronized File getBaseDir()61 {62 try {63 if (baseDirectory == null)64 {65 removeOldReports();66 File projectRoot = new File(String.format("%s/%s", URLDecoder.decode(System.getProperty("user.dir"), "utf-8"),67 Configuration.get(Parameter.PROJECT_REPORT_DIRECTORY)));68 if (!projectRoot.exists())69 {70 boolean isCreated = projectRoot.mkdirs();71 if (!isCreated)72 {73 throw new RuntimeException("Folder not created: " + projectRoot.getAbsolutePath());74 }75 }76 rootID = System.currentTimeMillis();77 String directory = String.format("%s/%s/%d", URLDecoder.decode(System.getProperty("user.dir"), "utf-8"),78 Configuration.get(Parameter.PROJECT_REPORT_DIRECTORY), rootID);79 File baseDirectoryTmp = new File(directory); 80 boolean isCreated = baseDirectoryTmp.mkdir();81 if (!isCreated)82 {83 throw new RuntimeException("Folder not created: " + baseDirectory.getAbsolutePath());84 }85 86 baseDirectory = baseDirectoryTmp;87 }88 } catch (UnsupportedEncodingException e) {89 throw new RuntimeException("Folder not created: " + baseDirectory.getAbsolutePath());90 }91 return baseDirectory;92 }93 94 public static boolean isBaseDireCreated() {95 return baseDirectory != null;96 }97 public static synchronized File getTempDir()98 {99 if (tempDirectory == null)100 {101 tempDirectory = new File(String.format("%s/%s", getBaseDir().getAbsolutePath(), TEMP_FOLDER));102 boolean isCreated = tempDirectory.mkdir();103 if (!isCreated)104 {105 throw new RuntimeException("Folder not created: " + tempDirectory.getAbsolutePath());106 }107 }108 return tempDirectory;109 }110 111 public static synchronized void removeTempDir()112 {113 if (tempDirectory != null)114 {115 try {116 FileUtils.deleteDirectory(tempDirectory);117 } catch (IOException e) {118 LOGGER.debug("Unable to remove artifacts temp directory!", e);119 }120 }121 }122 123 public static synchronized File getArtifactsFolder()124 {125 if (artifactsDirectory == null)126 {127 try {128 artifactsDirectory = new File(String.format("%s/%s", URLDecoder.decode(getBaseDir().getAbsolutePath(), "utf-8"), ARTIFACTS_FOLDER));129 } catch (UnsupportedEncodingException e) {130 throw new RuntimeException("Folder not created: " + artifactsDirectory.getAbsolutePath());131 }132 boolean isCreated = artifactsDirectory.mkdir();133 if (!isCreated)134 {135 throw new RuntimeException("Folder not created: " + artifactsDirectory.getAbsolutePath());136 }137 }138 return artifactsDirectory;139 }140 141 public static synchronized File getMetadataFolder()142 {143 if (metaDataDirectory == null)144 {145 try {146 metaDataDirectory = new File(String.format("%s/%s/metadata", URLDecoder.decode(getBaseDir().getAbsolutePath(), "utf-8"), ARTIFACTS_FOLDER));147 } catch (UnsupportedEncodingException e) {148 throw new RuntimeException("Artifacts metadata folder not created: " + metaDataDirectory.getAbsolutePath());149 }150 boolean isCreated = metaDataDirectory.mkdir();151 if (!isCreated)152 {153 throw new RuntimeException("Artifacts metadata folder not created: " + metaDataDirectory.getAbsolutePath());154 }155 }156 return metaDataDirectory;157 }158 /**159 * Check that Artifacts Folder exists.160 * @return boolean161 */162 public static boolean isArtifactsFolderExists() {163 try {164 File f = new File(String.format("%s/%s", getBaseDir().getAbsolutePath(), ARTIFACTS_FOLDER));165 if (f.exists() && f.isDirectory()) {166 return true;167 }168 } catch (Exception e) {169 LOGGER.debug("Error happen during checking that Artifactory Folder exists or not. Error: "+e.getMessage());170 }171 return false;172 }173 public static List<File> getAllArtifacts()174 {175 return Arrays.asList(getArtifactsFolder().listFiles());176 }177 178 public static File getArtifact(String name)179 {180 File artifact = null;181 for(File file : getAllArtifacts())182 {183 if(file.getName().equals(name))184 {185 artifact = file;186 break;187 }188 }189 return artifact;190 }191 192 public static void deleteAllArtifacts()193 {194 for(File file : getAllArtifacts())195 {196 file.delete();197 }198 }199 200 public static void deleteArtifact(String name)201 {202 for(File file : getAllArtifacts())203 {204 if(file.getName().equals(name))205 {206 file.delete();207 break;208 }209 }210 }211 212 public static void saveArtifact(String name, InputStream source) throws IOException213 {214 File artifact = new File(String.format("%s/%s", getArtifactsFolder(), name));215 artifact.createNewFile();216 FileUtils.writeByteArrayToFile(artifact, IOUtils.toByteArray(source));217 }218 219 public static void saveArtifact(File source) throws IOException220 {221 File artifact = new File(String.format("%s/%s", getArtifactsFolder(), source.getName()));222 artifact.createNewFile();223 FileUtils.copyFile(source, artifact);224 }225 /**226 * Crates new screenshot directory at first call otherwise returns created227 * directory. Directory is specific for any new test launch.228 * 229 * @param test230 * = name of test.231 * @return test screenshot folder.232 */233 public static synchronized File getTestDir(String test)234 {235 if (test == null) {236 test = "unknown";237 }238 String directory = String.format("%s/%s", getBaseDir(), test.replaceAll("[^a-zA-Z0-9.-]", "_"));239 File screenDir = new File(directory);240 if (!screenDir.exists())241 {242 boolean isCreated = screenDir.mkdirs();243 if (!isCreated)244 {245 throw new RuntimeException("Folder not created: " + screenDir.getAbsolutePath());246 }247 File thumbDir = new File(screenDir.getAbsolutePath() + "/thumbnails");248 isCreated = thumbDir.mkdir();249 if (!isCreated)250 {251 throw new RuntimeException("Folder not created: " + thumbDir.getAbsolutePath());252 }253 }254 return screenDir;255 }256 /**257 * Removes emailable html report and oldest screenshots directories according to history size defined258 * in config.259 */260 private static void removeOldReports()261 {262 File baseDir = new File(String.format("%s/%s", System.getProperty("user.dir"),263 Configuration.get(Parameter.PROJECT_REPORT_DIRECTORY)));264 265 if (baseDir.exists())266 {267 //remove old emailable report268 File reportFile = new File(String.format("%s/%s/%s", System.getProperty("user.dir"),269 Configuration.get(Parameter.PROJECT_REPORT_DIRECTORY), SpecialKeywords.HTML_REPORT));270 // if file doesnt exists, then create it271 if (reportFile.exists()) {272 reportFile.delete();273 }274 275 List<File> files = FileManager.getFilesInDir(baseDir);276 List<File> screenshotFolders = new ArrayList<File>();277 for(File file : files)278 {279 if(file.isDirectory() && !file.getName().startsWith("."))280 {281 screenshotFolders.add(file);282 }283 }284 285 int maxHistory = Configuration.getInt(Parameter.MAX_SCREENSHOOT_HISTORY);286 if (screenshotFolders.size() + 1 > maxHistory && maxHistory != 0)287 {288 Comparator<File> comp = new Comparator<File>()289 {290 @Override291 public int compare(File file1, File file2)292 {293 return file2.getName().compareTo(file1.getName());294 }295 };296 Collections.sort(screenshotFolders, comp);297 for (int i = maxHistory - 1; i < screenshotFolders.size(); i++)298 {299 if (screenshotFolders.get(i).getName().equals("gallery-lib")) {300 continue;301 }302 try303 {304 FileUtils.deleteDirectory(screenshotFolders.get(i));305 }306 catch (IOException e)307 {308 LOGGER.error(e.getMessage());309 }310 }311 }312 }313 }314 public static void removeTestReport(String test)315 {316 try317 {318 File toDelete = new File(ReportContext.getBaseDir() + "/" + test.replaceAll("[^a-zA-Z0-9.-]", "_"));319 FileUtils.deleteDirectory(toDelete);320 }321 catch (IOException e)322 {323 LOGGER.error(e.getMessage());324 }325 }326 327 public static void removeTestScreenshots(String test)328 {329 try330 {331 // Lists all files in folder332 File parentFolder = new File(ReportContext.getBaseDir() + "/" + test.replaceAll("[^a-zA-Z0-9.-]", "_"));333 File fList[] = parentFolder.listFiles();334 for (int i = 0; i < fList.length; i++) {335 if (fList[i].getName().endsWith(".png") || fList[i].getName().endsWith(".mp4") || fList[i].getName().endsWith(".html")) {336 fList[i].delete();337 }338 }339 File thumbnailsFolder = new File(ReportContext.getBaseDir() + "/" + test.replaceAll("[^a-zA-Z0-9.-]", "_") + "/thumbnails");340 thumbnailsFolder.delete();341 }342 catch (Exception e)343 {344 LOGGER.error("Exception discovered during screenshots/video removing! " + e.getMessage());345 }346 }347 348 public static void generateHtmlReport(String content) {349 generateHtmlReport(content, SpecialKeywords.HTML_REPORT);350 }351 352 public static void generateHtmlReport(String content, String emailableReport) {353 try {...

Full Screen

Full Screen

Source:CucumberRunner.java Github

copy

Full Screen

...117 private void generateCucumberReport() {118 String buildNumber = Configuration.get(Parameter.APP_VERSION);119 try {120 // String RootDir = System.getProperty("user.dir");121 File file = ReportContext.getBaseDir();122 File reportOutputDirectory = new File(String.format("%s/%s", file, SpecialKeywords.CUCUMBER_REPORT_FOLDER));123 File dir = new File("target/");124 File[] finder = dir.listFiles(new FilenameFilter() {125 public boolean accept(File dir, String filename) {126 return filename.endsWith(".json");127 }128 });129 List<String> list = new ArrayList<String>();130 for (File fl : finder) {131 LOGGER.info("Report json: " + fl.getName());132 list.add("target/" + fl.getName());133 }134 // buildNumber should be parsable Integer135 buildNumber = buildNumber.replace(".", "").replace(",", "");136 if (list.size() > 0) {137 // String buildNumber = "1";138 // String buildProject = "CUCUMBER";139 // boolean skippedFails = true;140 // boolean pendingFails = true;141 // boolean undefinedFails = true;142 // boolean missingFails = true;143 net.masterthought.cucumber.Configuration configuration = new net.masterthought.cucumber.Configuration(reportOutputDirectory,144 "Cucumber Test Results");145 // configuration.setStatusFlags(skippedFails, pendingFails, undefinedFails, missingFails);146 // configuration.setParallelTesting(parallelTesting);147 // configuration.setJenkinsBasePath(jenkinsBasePath);148 // configuration.setRunWithJenkins(runWithJenkins);149 configuration.setBuildNumber(buildNumber);150 ReportBuilder reportBuilder = new ReportBuilder(list, configuration);151 reportBuilder.generateReports();152 if (!Configuration.isNull(Parameter.REPORT_URL)) {153 String reportUrl = Configuration.get(Parameter.REPORT_URL);154 if (reportUrl.endsWith(ZAFIRA_REPORT_CI)) {155 Artifact.attachReferenceToTestRun(CUCUMBER_REPORT_NAME, reportUrl.replace(ZAFIRA_REPORT_CI, CUCUMBER_REPORT_CI));156 } else {157 Artifact.attachReferenceToTestRun(CUCUMBER_REPORT_NAME, ReportContext.getCucumberReportLink());158 }159 }160 } else {161 LOGGER.info("There are no json files for cucumber report.");162 return;163 }164 } catch (Exception e) {165 LOGGER.error(e.getMessage());166 }167 }168 /**169 * Check that CucumberReport Folder exists.170 *171 * @return boolean172 */173 public static boolean isCucumberReportFolderExists() {174 try {175 File reportOutputDirectory = new File(String.format("%s/%s", ReportContext.getBaseDir(), SpecialKeywords.CUCUMBER_REPORT_FOLDER));176 if (reportOutputDirectory.exists() && reportOutputDirectory.isDirectory()) {177 if (reportOutputDirectory.list().length > 0) {178 LOGGER.debug("Cucumber Report Folder is not empty!");179 return true;180 } else {181 LOGGER.error("Cucumber Report Folder is empty!");182 return false;183 }184 }185 } catch (Exception e) {186 LOGGER.debug("Error happen during checking that CucumberReport Folder exists or not. Error: " + e.getMessage());187 }188 return false;189 }...

Full Screen

Full Screen

getBaseDir

Using AI Code Generation

copy

Full Screen

1String baseDir = ReportContext.getBaseDir();2String baseDir = ReportContext.getBaseDir();3String baseDir = ReportContext.getBaseDir();4String baseDir = ReportContext.getBaseDir();5String baseDir = ReportContext.getBaseDir();6String baseDir = ReportContext.getBaseDir();7String baseDir = ReportContext.getBaseDir();8String baseDir = ReportContext.getBaseDir();9String baseDir = ReportContext.getBaseDir();10String baseDir = ReportContext.getBaseDir();11String baseDir = ReportContext.getBaseDir();12String baseDir = ReportContext.getBaseDir();13String baseDir = ReportContext.getBaseDir();

Full Screen

Full Screen

getBaseDir

Using AI Code Generation

copy

Full Screen

1String baseDir = ReportContext.getBaseDir();2String baseDir = ReportContext.getBaseDir();3String baseDir = ReportContext.getBaseDir();4String baseDir = ReportContext.getBaseDir();5String baseDir = ReportContext.getBaseDir();6String baseDir = ReportContext.getBaseDir();7String baseDir = ReportContext.getBaseDir();8String baseDir = ReportContext.getBaseDir();9String baseDir = ReportContext.getBaseDir();10String baseDir = ReportContext.getBaseDir();11String baseDir = ReportContext.getBaseDir();12String baseDir = ReportContext.getBaseDir();13String baseDir = ReportContext.getBaseDir();14String baseDir = ReportContext.getBaseDir();

Full Screen

Full Screen

getBaseDir

Using AI Code Generation

copy

Full Screen

1String baseDir = ReportContext.getBaseDir();2String testOutputDir = ReportContext.getTestOutputDir();3String testOutputDir = ReportContext.getTestOutputDir();4String testOutputDir = ReportContext.getTestOutputDir();5String testOutputDir = ReportContext.getTestOutputDir();6String testOutputDir = ReportContext.getTestOutputDir();7String testOutputDir = ReportContext.getTestOutputDir();8String testOutputDir = ReportContext.getTestOutputDir();9String testOutputDir = ReportContext.getTestOutputDir();10String testOutputDir = ReportContext.getTestOutputDir();11String testOutputDir = ReportContext.getTestOutputDir();12String testOutputDir = ReportContext.getTestOutputDir();13String testOutputDir = ReportContext.getTestOutputDir();14String testOutputDir = ReportContext.getTestOutputDir();15String testOutputDir = ReportContext.getTestOutputDir();

Full Screen

Full Screen

getBaseDir

Using AI Code Generation

copy

Full Screen

1public class 1 {2public static void main(String[] args) {3System.out.println(ReportContext.getBaseDir());4}5}6public class 2 {7public static void main(String[] args) {8System.out.println(ReportContext.getBaseDir());9}10}11public class 3 {12public static void main(String[] args) {13System.out.println(ReportContext.getBaseDir());14}15}16public class 4 {17public static void main(String[] args) {18System.out.println(ReportContext.getBaseDir());19}20}21public class 5 {22public static void main(String[] args) {23System.out.println(ReportContext.getBaseDir());24}25}26public class 6 {27public static void main(String[] args) {28System.out.println(ReportContext.getBaseDir());29}30}31public class 7 {32public static void main(String[] args) {33System.out.println(ReportContext.getBaseDir());34}35}36public class 8 {37public static void main(String[] args) {38System.out.println(ReportContext.getBaseDir());39}40}41public class 9 {42public static void main(String[] args) {43System.out.println(ReportContext.getBaseDir());44}45}

Full Screen

Full Screen

getBaseDir

Using AI Code Generation

copy

Full Screen

1String path = ReportContext.getBaseDir() + "/myFolder/myFile.txt";2String path = ReportContext.getBaseDir() + "/myFolder/myFile.txt";3String path = ReportContext.getBaseDir() + "/myFolder/myFile.txt";4String path = ReportContext.getBaseDir() + "/myFolder/myFile.txt";5String path = ReportContext.getBaseDir() + "/myFolder/myFile.txt";6String path = ReportContext.getBaseDir() + "/myFolder/myFile.txt";7String path = ReportContext.getBaseDir() + "/myFolder/myFile.txt";8String path = ReportContext.getBaseDir() + "/myFolder/myFile.txt";9String path = ReportContext.getBaseDir() + "/myFolder/myFile.txt";10String path = ReportContext.getBaseDir() + "/myFolder/myFile.txt";11String path = ReportContext.getBaseDir() + "/myFolder/myFile.txt";12String path = ReportContext.getBaseDir() + "/myFolder/myFile.txt";13String path = ReportContext.getBaseDir() + "/myFolder/myFile.txt";

Full Screen

Full Screen

getBaseDir

Using AI Code Generation

copy

Full Screen

1public void getBaseDir() {2 String baseDir = ReportContext.getBaseDir();3 System.out.println("Base directory is : " + baseDir);4}5public void getBaseDir() {6 String baseDir = ReportContext.getBaseDir();7 System.out.println("Base directory is : " + baseDir);8}9public void getBaseDir() {10 String baseDir = ReportContext.getBaseDir();11 System.out.println("Base directory is : " + baseDir);12}13public void getBaseDir() {14 String baseDir = ReportContext.getBaseDir();15 System.out.println("Base directory is : " + baseDir);16}17public void getBaseDir() {18 String baseDir = ReportContext.getBaseDir();19 System.out.println("Base directory is : " + baseDir);20}21public void getBaseDir() {22 String baseDir = ReportContext.getBaseDir();23 System.out.println("Base directory is : " + baseDir);24}25public void getBaseDir() {26 String baseDir = ReportContext.getBaseDir();27 System.out.println("Base directory is : " + baseDir);28}29public void getBaseDir() {30 String baseDir = ReportContext.getBaseDir();31 System.out.println("Base directory is : " + baseDir);32}

Full Screen

Full Screen

getBaseDir

Using AI Code Generation

copy

Full Screen

1String baseDir = ReportContext.getBaseDir();2System.out.println("BaseDir of the project is : "+baseDir);3String baseDir = ReportContext.getBaseDir();4System.out.println("BaseDir of the project is : "+baseDir);5String baseDir = ReportContext.getBaseDir();6System.out.println("BaseDir of the project is : "+baseDir);7String baseDir = ReportContext.getBaseDir();8System.out.println("BaseDir of the project is : "+baseDir);9String baseDir = ReportContext.getBaseDir();10System.out.println("BaseDir of the project is : "+baseDir);11String baseDir = ReportContext.getBaseDir();12System.out.println("BaseDir of the project is : "+baseDir);13String baseDir = ReportContext.getBaseDir();14System.out.println("BaseDir of the project is : "+baseDir);15String baseDir = ReportContext.getBaseDir();16System.out.println("BaseDir of the project is : "+baseDir);17String baseDir = ReportContext.getBaseDir();18System.out.println("BaseDir of the project is : "+baseDir);

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful