Best Carina code snippet using com.qaprosoft.carina.core.foundation.log.ThreadLogAppender.ThreadLogAppender
Source:AbstractTest.java
...54import com.qaprosoft.carina.core.foundation.api.APIMethodBuilder;55import com.qaprosoft.carina.core.foundation.dataprovider.core.DataProviderFactory;56import com.qaprosoft.carina.core.foundation.jira.Jira;57import com.qaprosoft.carina.core.foundation.listeners.AbstractTestListener;58import com.qaprosoft.carina.core.foundation.log.ThreadLogAppender;59import com.qaprosoft.carina.core.foundation.report.Artifacts;60import com.qaprosoft.carina.core.foundation.report.HtmlReportGenerator;61import com.qaprosoft.carina.core.foundation.report.ReportContext;62import com.qaprosoft.carina.core.foundation.report.TestResultItem;63import com.qaprosoft.carina.core.foundation.report.TestResultType;64import com.qaprosoft.carina.core.foundation.report.email.EmailManager;65import com.qaprosoft.carina.core.foundation.report.email.EmailReportGenerator;66import com.qaprosoft.carina.core.foundation.report.email.EmailReportItemCollector;67import com.qaprosoft.carina.core.foundation.report.spira.Spira;68import com.qaprosoft.carina.core.foundation.report.testrail.TestRail;69import com.qaprosoft.carina.core.foundation.utils.Configuration;70import com.qaprosoft.carina.core.foundation.utils.Configuration.DriverMode;71import com.qaprosoft.carina.core.foundation.utils.Configuration.Parameter;72import com.qaprosoft.carina.core.foundation.utils.DateUtils;73import com.qaprosoft.carina.core.foundation.utils.JsonUtils;74import com.qaprosoft.carina.core.foundation.utils.Messager;75import com.qaprosoft.carina.core.foundation.utils.R;76import com.qaprosoft.carina.core.foundation.utils.SpecialKeywords;77import com.qaprosoft.carina.core.foundation.utils.metadata.MetadataCollector;78import com.qaprosoft.carina.core.foundation.utils.metadata.model.ElementsInfo;79import com.qaprosoft.carina.core.foundation.utils.naming.TestNamingUtil;80import com.qaprosoft.carina.core.foundation.utils.resources.I18N;81import com.qaprosoft.carina.core.foundation.utils.resources.L10N;82import com.qaprosoft.carina.core.foundation.utils.resources.L10Nparser;83import com.qaprosoft.carina.core.foundation.webdriver.DriverPool;84import com.qaprosoft.carina.core.foundation.webdriver.device.DevicePool;85/*86 * AbstractTest - base test for UI and API tests.87 * 88 * @author Alex Khursevich89 */90@Listeners({AbstractTestListener.class})91public abstract class AbstractTest // extends DriverHelper92{93 protected static final Logger LOGGER = Logger.getLogger(AbstractTest.class);94 protected APIMethodBuilder apiMethodBuilder;95 protected static final long IMPLICIT_TIMEOUT = Configuration.getLong(Parameter.IMPLICIT_TIMEOUT);96 protected static final long EXPLICIT_TIMEOUT = Configuration.getLong(Parameter.EXPLICIT_TIMEOUT);97 protected static final String SUITE_TITLE = "%s%s%s - %s (%s%s)";98 protected static final String XML_SUITE_NAME = " (%s)";99 protected static ThreadLocal<String> suiteNameAppender = new ThreadLocal<String>();100 101 // 3rd party integrations102 protected String browserVersion = "";103 protected long startDate;104 @BeforeSuite(alwaysRun = true)105 public void executeBeforeTestSuite(ITestContext context) throws Throwable {106 107 DevicePool.addDevices();108 // Add shutdown hook109 Runtime.getRuntime().addShutdownHook(new ShutdownHook());110 // Set log4j properties111 PropertyConfigurator.configure(ClassLoader.getSystemResource("log4j.properties"));112 // Set SoapUI log4j properties113 System.setProperty("soapui.log4j.config", "./src/main/resources/soapui-log4j.xml");114 try {115 Logger root = Logger.getRootLogger();116 Enumeration<?> allLoggers = root.getLoggerRepository().getCurrentCategories();117 while (allLoggers.hasMoreElements()) {118 Category tmpLogger = (Category) allLoggers.nextElement();119 if (tmpLogger.getName().equals("com.qaprosoft.carina.core")) {120 tmpLogger.setLevel(Level.toLevel(Configuration.get(Parameter.CORE_LOG_LEVEL)));121 }122 }123 } catch (NoSuchMethodError e) {124 LOGGER.error("Unable to redefine logger level due to the conflicts between log4j and slf4j!");125 }126 startDate = new Date().getTime();127 LOGGER.info(Configuration.asString());128 // Configuration.validateConfiguration();129 LOGGER.debug("Default thread_count=" + context.getCurrentXmlTest().getSuite().getThreadCount());130 context.getCurrentXmlTest().getSuite().setThreadCount(Configuration.getInt(Parameter.THREAD_COUNT));131 LOGGER.debug("Updated thread_count=" + context.getCurrentXmlTest().getSuite().getThreadCount());132 // update DataProviderThreadCount if any property is provided otherwise sync with value from suite xml file133 int count = Configuration.getInt(Parameter.DATA_PROVIDER_THREAD_COUNT);134 if (count > 0) {135 LOGGER.debug("Updated 'data_provider_thread_count' from "136 + context.getCurrentXmlTest().getSuite().getDataProviderThreadCount() + " to " + count);137 context.getCurrentXmlTest().getSuite().setDataProviderThreadCount(count);138 } else {139 LOGGER.debug("Synching data_provider_thread_count with values from suite xml file...");140 R.CONFIG.put(Parameter.DATA_PROVIDER_THREAD_COUNT.getKey(), String.valueOf(context.getCurrentXmlTest().getSuite().getDataProviderThreadCount()));141 LOGGER.debug("Updated 'data_provider_thread_count': " + Configuration.getInt(Parameter.DATA_PROVIDER_THREAD_COUNT));142 }143 LOGGER.debug("Default data_provider_thread_count="144 + context.getCurrentXmlTest().getSuite().getDataProviderThreadCount());145 LOGGER.debug("Updated data_provider_thread_count="146 + context.getCurrentXmlTest().getSuite().getDataProviderThreadCount());147 if (!Configuration.isNull(Parameter.URL)) {148 if (!Configuration.get(Parameter.URL).isEmpty()) {149 RestAssured.baseURI = Configuration.get(Parameter.URL);150 }151 }152 try {153 L10N.init();154 } catch (Exception e) {155 LOGGER.error("L10N bundle is not initialized successfully!", e);156 }157 try {158 I18N.init();159 } catch (Exception e) {160 LOGGER.error("I18N bundle is not initialized successfully!", e);161 }162 try {163 L10Nparser.init();164 } catch (Exception e) {165 LOGGER.error("L10Nparser bundle is not initialized successfully!", e);166 }167 try {168 TestRail.updateBeforeSuite(context, this.getClass().getName(), getTitle(context));169 } catch (Exception e) {170 LOGGER.error("TestRail is not initialized successfully!", e);171 }172 try {173 if (!Configuration.get(Parameter.ACCESS_KEY_ID).isEmpty()) {174 LOGGER.info("Initializing AWS S3 client...");175 AmazonS3Manager.getInstance().initS3client(Configuration.get(Parameter.ACCESS_KEY_ID),176 Configuration.get(Parameter.SECRET_KEY));177 updateS3AppPath();178 }179 } catch (Exception e) {180 LOGGER.error("AWS S3 client is not initialized successfully!", e);181 }182 183 // moved from UITest->executeBeforeTestSuite184 String customCapabilities = Configuration.get(Parameter.CUSTOM_CAPABILITIES);185 if (!customCapabilities.isEmpty()) {186 //redefine core properties using custom capabilities file187 Map<String, String> properties = Configuration.loadCoreProperties(customCapabilities);188 //reregister device if mobile core properties are redefined 189 DevicePool.addDevice(properties);190 }191 }192 193 @BeforeClass(alwaysRun = true)194 public void executeBeforeTestClass(ITestContext context) throws Throwable {195 // do nothing for now196 }197 @AfterClass(alwaysRun = true)198 public void executeAfterTestClass(ITestContext context) throws Throwable {199 if (Configuration.getDriverMode() == DriverMode.CLASS_MODE) {200 LOGGER.debug("Deinitialize driver(s) in UITest->AfterClass.");201 quitDrivers();202 }203 }204 @BeforeMethod(alwaysRun = true)205 public void executeBeforeTestMethod(XmlTest xmlTest, Method testMethod,206 ITestContext context) throws Throwable {207 // do nothing for now208 Spira.registerStepsFromAnnotation(testMethod);209 210 apiMethodBuilder = new APIMethodBuilder();211 }212 213 214 @AfterMethod(alwaysRun = true)215 public void executeAfterTestMethod(ITestResult result) {216 try {217 DriverMode driverMode = Configuration.getDriverMode();218 if (driverMode == DriverMode.METHOD_MODE) {219 LOGGER.debug("Deinitialize driver(s) in @AfterMethod.");220 quitDrivers();221 }222 // TODO: improve later removing duplicates with AbstractTestListener223 //handle Zafira already passed exception for re-run and do nothing. maybe return should be enough224 if (result.getThrowable() != null && result.getThrowable().getMessage() != null225 && result.getThrowable().getMessage().startsWith(SpecialKeywords.ALREADY_PASSED)) {226 // [VD] it is prohibited to release TestInfoByThread in this place.!227 return;228 }229 //handle AbstractTest->SkipExecution230 if (result.getThrowable() != null && result.getThrowable().getMessage() != null231 && result.getThrowable().getMessage().startsWith(SpecialKeywords.SKIP_EXECUTION)) {232 // [VD] it is prohibited to release TestInfoByThread in this place.!233 return;234 }235 String test = TestNamingUtil.getCanonicalTestName(result);236 List<String> tickets = Jira.getTickets(result);237 result.setAttribute(SpecialKeywords.JIRA_TICKET, tickets);238 Jira.updateAfterTest(result);239 // Populate Spira Steps240 Spira.updateAfterTest(result, (String) result.getTestContext().getAttribute(SpecialKeywords.TEST_FAILURE_MESSAGE), tickets);241 Spira.clear();242 // Populate TestRail Cases243 if (!R.ZAFIRA.getBoolean("zafira_enabled")){244 result.setAttribute(SpecialKeywords.TESTRAIL_CASES_ID, TestRail.getCases(result));245 TestRail.updateAfterTest(result, (String) result.getTestContext().getAttribute(SpecialKeywords.TEST_FAILURE_MESSAGE));246 TestRail.clearCases();247 }248 //we shouldn't deregister info here as all retries will not work249 //TestNamingUtil.releaseZafiraTest();250 // clear jira tickets to be sure that next test is not affected.251 Jira.clearTickets();252 Artifacts.clearArtifacts();253 try {254 ThreadLogAppender tla = (ThreadLogAppender) Logger.getRootLogger().getAppender("ThreadLogAppender");255 if (tla != null) {256 tla.closeResource(test);257 }258 } catch (NoSuchMethodError e) {259 LOGGER.error("Unable to redefine logger level due to the conflicts between log4j and slf4j!");260 }261 } catch (Exception e) {262 LOGGER.error("Exception in AbstractTest->executeAfterTestMethod: " + e.getMessage());263 e.printStackTrace();264 }265 }266 @AfterSuite(alwaysRun = true)267 public void executeAfterTestSuite(ITestContext context) {268 try {...
Source:ReportContext.java
...40import org.apache.commons.lang3.StringUtils;41import org.apache.log4j.Logger;42import org.imgscalr.Scalr;43import com.qaprosoft.carina.core.foundation.commons.SpecialKeywords;44import com.qaprosoft.carina.core.foundation.log.ThreadLogAppender;45import com.qaprosoft.carina.core.foundation.utils.Configuration;46import com.qaprosoft.carina.core.foundation.utils.Configuration.Parameter;47import com.qaprosoft.carina.core.foundation.utils.FileManager;48import com.qaprosoft.carina.core.foundation.utils.R;49import com.qaprosoft.carina.core.foundation.utils.ZipManager;50/*51 * Be careful with LOGGER usage here because potentially it could do recursive call together with ThreadLogAppender functionality52 */53public class ReportContext {54 private static final Logger LOGGER = Logger.getLogger(ReportContext.class);55 public static final String ARTIFACTS_FOLDER = "artifacts";56 57 private static final String GALLERY_ZIP = "gallery-lib.zip";58 private static final String REPORT_NAME = "/report.html";59 private static final int MAX_IMAGE_TITLE = 300;60 private static final String TITLE = "Test steps demo";61 public static final String TEMP_FOLDER = "temp";62 private static File baseDirectory = null;63 private static File tempDirectory;64 private static File artifactsDirectory;65 private static File metaDataDirectory;66 private static long rootID;67 private static final ThreadLocal<File> testDirectory = new ThreadLocal<File>();68 private static final ExecutorService executor = Executors.newCachedThreadPool();69 70 // Collects screenshot comments. Screenshot comments are associated using screenshot file name.71 private static Map<String, String> screenSteps = Collections.synchronizedMap(new HashMap<String, String>());72 public static long getRootID() {73 return rootID;74 }75 /**76 * Crates new screenshot directory at first call otherwise returns created directory. Directory is specific for any77 * new test suite launch.78 * 79 * @return root screenshot folder for test launch.80 */81 public static synchronized File getBaseDir() {82 try {83 if (baseDirectory == null) {84 removeOldReports();85 File projectRoot = new File(String.format("%s/%s", URLDecoder.decode(System.getProperty("user.dir"), "utf-8"),86 Configuration.get(Parameter.PROJECT_REPORT_DIRECTORY)));87 if (!projectRoot.exists()) {88 boolean isCreated = projectRoot.mkdirs();89 if (!isCreated) {90 throw new RuntimeException("Folder not created: " + projectRoot.getAbsolutePath());91 }92 }93 rootID = System.currentTimeMillis();94 String directory = String.format("%s/%s/%d", URLDecoder.decode(System.getProperty("user.dir"), "utf-8"),95 Configuration.get(Parameter.PROJECT_REPORT_DIRECTORY), rootID);96 File baseDirectoryTmp = new File(directory);97 boolean isCreated = baseDirectoryTmp.mkdir();98 if (!isCreated) {99 throw new RuntimeException("Folder not created: " + baseDirectory.getAbsolutePath());100 }101 baseDirectory = baseDirectoryTmp;102 103 copyGalleryLib();104 }105 } catch (UnsupportedEncodingException e) {106 throw new RuntimeException("Folder not created: " + baseDirectory.getAbsolutePath());107 }108 return baseDirectory;109 }110 public static boolean isBaseDirCreated() {111 return baseDirectory != null;112 }113 public static synchronized File getTempDir() {114 if (tempDirectory == null) {115 tempDirectory = new File(String.format("%s/%s", getBaseDir().getAbsolutePath(), TEMP_FOLDER));116 boolean isCreated = tempDirectory.mkdir();117 if (!isCreated) {118 throw new RuntimeException("Folder not created: " + tempDirectory.getAbsolutePath());119 }120 }121 return tempDirectory;122 }123 public static synchronized void removeTempDir() {124 if (tempDirectory != null) {125 try {126 FileUtils.deleteDirectory(tempDirectory);127 } catch (IOException e) {128 LOGGER.debug("Unable to remove artifacts temp directory!", e);129 }130 }131 }132 public static synchronized File getArtifactsFolder() {133 if (artifactsDirectory == null) {134 String absolutePath = getBaseDir().getAbsolutePath();135 136 try {137 if (Configuration.get(Parameter.CUSTOM_ARTIFACTS_FOLDER).isEmpty()) {138 artifactsDirectory = new File(String.format("%s/%s", URLDecoder.decode(absolutePath, "utf-8"), ARTIFACTS_FOLDER));139 } else {140 artifactsDirectory = new File(Configuration.get(Parameter.CUSTOM_ARTIFACTS_FOLDER));141 }142 } catch (UnsupportedEncodingException e) {143 throw new RuntimeException("Artifacts folder not created in base dir: " + absolutePath);144 }145 146 boolean isCreated = artifactsDirectory.exists() && artifactsDirectory.isDirectory();147 if (!isCreated) {148 isCreated = artifactsDirectory.mkdir();149 } else {150 LOGGER.info("Artifacts folder already exists: " + artifactsDirectory.getAbsolutePath());151 }152 153 if (!isCreated) {154 throw new RuntimeException("Artifacts folder not created: " + artifactsDirectory.getAbsolutePath());155 }156 }157 return artifactsDirectory;158 }159 public static synchronized File getMetadataFolder() {160 if (metaDataDirectory == null) {161 String absolutePath = getBaseDir().getAbsolutePath();162 try {163 metaDataDirectory = new File(String.format("%s/%s/metadata", URLDecoder.decode(absolutePath, "utf-8")), ARTIFACTS_FOLDER);164 } catch (UnsupportedEncodingException e) {165 throw new RuntimeException("Artifacts metadata folder is not created in base dir: " + absolutePath);166 }167 boolean isCreated = metaDataDirectory.mkdir();168 if (!isCreated) {169 throw new RuntimeException("Artifacts metadata folder is not created in base dir: " + absolutePath);170 }171 }172 return metaDataDirectory;173 }174 /**175 * Check that Artifacts Folder exists.176 * 177 * @return boolean178 */179 public static boolean isArtifactsFolderExists() {180 try {181 File f = new File(String.format("%s/%s", getBaseDir().getAbsolutePath(), ARTIFACTS_FOLDER));182 if (f.exists() && f.isDirectory()) {183 return true;184 }185 } catch (Exception e) {186 LOGGER.debug("Error happen during checking that Artifactory Folder exists or not. Error: " + e.getMessage());187 }188 return false;189 }190 public static List<File> getAllArtifacts() {191 return Arrays.asList(getArtifactsFolder().listFiles());192 }193 public static File getArtifact(String name) {194 File artifact = null;195 for (File file : getAllArtifacts()) {196 if (file.getName().equals(name)) {197 artifact = file;198 break;199 }200 }201 return artifact;202 }203 public static void deleteAllArtifacts() {204 for (File file : getAllArtifacts()) {205 file.delete();206 }207 }208 public static void deleteArtifact(String name) {209 for (File file : getAllArtifacts()) {210 if (file.getName().equals(name)) {211 file.delete();212 break;213 }214 }215 }216 public static void saveArtifact(String name, InputStream source) throws IOException {217 File artifact = new File(String.format("%s/%s", getArtifactsFolder(), name));218 artifact.createNewFile();219 FileUtils.writeByteArrayToFile(artifact, IOUtils.toByteArray(source));220 }221 public static void saveArtifact(File source) throws IOException {222 File artifact = new File(String.format("%s/%s", getArtifactsFolder(), source.getName()));223 artifact.createNewFile();224 FileUtils.copyFile(source, artifact);225 }226 /**227 * Creates new test directory at first call otherwise returns created directory. Directory is specific for any new228 * test launch.229 * 230 * @return test log/screenshot folder.231 */232 public static File getTestDir() {233 File testDir = testDirectory.get();234 if (testDir == null) {235 String uniqueDirName = UUID.randomUUID().toString();236 String directory = String.format("%s/%s", getBaseDir(), uniqueDirName);237 // System.out.println("First request for test dir. Just generate unique folder: " + directory);238 testDir = new File(directory);239 File thumbDir = new File(testDir.getAbsolutePath() + "/thumbnails");240 if (!thumbDir.mkdirs()) {241 throw new RuntimeException("Test Folder(s) not created: " + testDir.getAbsolutePath() + " and/or " + thumbDir.getAbsolutePath());242 }243 }244 testDirectory.set(testDir);245 return testDir;246 }247 /**248 * Rename test directory from unique number to valid human readable content using test method name.249 * 250 * @param test251 * name252 * 253 * @return test log/screenshot folder.254 */255 public static File renameTestDir(String test) {256 File testDir = testDirectory.get();257 if (testDir != null) {258 // remove info about old directory to register new one for the next259 // test. Extra after method/class/suite custom messages will be260 // logged into the next test.log file261 testDirectory.remove();262 File newTestDir = new File(String.format("%s/%s", getBaseDir(), test.replaceAll("[^a-zA-Z0-9.-]", "_")));263 if (!newTestDir.exists()) {264 // close ThreadLogAppender resources before renaming265 try {266 ThreadLogAppender tla = (ThreadLogAppender) Logger.getRootLogger().getAppender("ThreadLogAppender");267 if (tla != null) {268 tla.close();269 }270 } catch (NoSuchMethodError e) {271 LOGGER.error("Unable to redefine logger level due to the conflicts between log4j and slf4j!");272 }273 testDir.renameTo(newTestDir);274 generateTestReport(newTestDir);275 }276 } else {277 LOGGER.error("Unexpected case with absence of test.log for '" + test + "'");278 }279 280 return testDir;...
Source:AbstractTestListener.java
...33import org.testng.ITestResult;3435import com.qaprosoft.carina.core.foundation.dataprovider.parser.DSBean;36import com.qaprosoft.carina.core.foundation.jira.Jira;37import com.qaprosoft.carina.core.foundation.log.ThreadLogAppender;38import com.qaprosoft.carina.core.foundation.report.Artifacts;39import com.qaprosoft.carina.core.foundation.report.ReportContext;40import com.qaprosoft.carina.core.foundation.report.TestResultItem;41import com.qaprosoft.carina.core.foundation.report.TestResultType;42import com.qaprosoft.carina.core.foundation.report.email.EmailReportItemCollector;43import com.qaprosoft.carina.core.foundation.retry.RetryAnalyzer;44import com.qaprosoft.carina.core.foundation.retry.RetryCounter;45import com.qaprosoft.carina.core.foundation.utils.Configuration;46import com.qaprosoft.carina.core.foundation.utils.Configuration.Parameter;47import com.qaprosoft.carina.core.foundation.utils.DateUtils;48import com.qaprosoft.carina.core.foundation.utils.Messager;49import com.qaprosoft.carina.core.foundation.utils.ParameterGenerator;50import com.qaprosoft.carina.core.foundation.utils.R;51import com.qaprosoft.carina.core.foundation.utils.SpecialKeywords;52import com.qaprosoft.carina.core.foundation.utils.StringGenerator;53import com.qaprosoft.carina.core.foundation.utils.naming.TestNamingUtil;54import com.qaprosoft.carina.core.foundation.webdriver.DriverPool;55import com.qaprosoft.carina.core.foundation.webdriver.Screenshot;56import com.qaprosoft.carina.core.foundation.webdriver.device.DevicePool;5758@SuppressWarnings("deprecation")59public class AbstractTestListener extends TestArgsListener60{61 private static final Logger LOGGER = Logger.getLogger(AbstractTestListener.class);6263 protected static ThreadLocal<TestResultItem> configFailures = new ThreadLocal<TestResultItem>();6465 private void startItem(ITestResult result, Messager messager)66 {6768 String test = TestNamingUtil.getCanonicalTestName(result);69 test = TestNamingUtil.associateTestInfo2Thread(test, Thread.currentThread().getId());7071 String deviceName = getDeviceName();72 messager.info(deviceName, test, DateUtils.now());73 }7475 private void passItem(ITestResult result, Messager messager)76 {77 String test = TestNamingUtil.getCanonicalTestName(result);7879 String deviceName = getDeviceName();8081 messager.info(deviceName, test, DateUtils.now());8283 EmailReportItemCollector84 .push(createTestResult(result, TestResultType.PASS, null, result.getMethod().getDescription()));85 result.getTestContext().removeAttribute(SpecialKeywords.TEST_FAILURE_MESSAGE);8687 TestNamingUtil.releaseTestInfoByThread();88 }8990 private String failItem(ITestResult result, Messager messager)91 {92 String test = TestNamingUtil.getCanonicalTestName(result);9394 String errorMessage = getFailureReason(result);95 96 takeScreenshot(result, "TEST FAILED - " + errorMessage);97 98 String deviceName = getDeviceName();99100 // TODO: remove hard-coded text101 if (!errorMessage.contains("All tests were skipped! Analyze logs to determine possible configuration issues."))102 {103 messager.info(deviceName, test, DateUtils.now(), errorMessage);104 if (!R.EMAIL.getBoolean("fail_full_stacktrace_in_report") && result.getThrowable() != null105 && result.getThrowable().getMessage() != null106 && !StringUtils.isEmpty(result.getThrowable().getMessage()))107 {108 EmailReportItemCollector.push(createTestResult(result, TestResultType.FAIL,109 result.getThrowable().getMessage(), result.getMethod().getDescription()));110 } else111 {112 EmailReportItemCollector.push(createTestResult(result, TestResultType.FAIL, errorMessage, result113 .getMethod().getDescription()));114 }115 }116117 result.getTestContext().removeAttribute(SpecialKeywords.TEST_FAILURE_MESSAGE);118 TestNamingUtil.releaseTestInfoByThread();119 return errorMessage;120 }121122 private String failRetryItem(ITestResult result, Messager messager, int count, int maxCount)123 {124 String test = TestNamingUtil.getCanonicalTestName(result);125126 String errorMessage = getFailureReason(result);127 128 takeScreenshot(result, "TEST FAILED - " + errorMessage);129 130 String deviceName = getDeviceName();131132 messager.info(deviceName, test, String.valueOf(count), String.valueOf(maxCount), errorMessage);133134 result.getTestContext().removeAttribute(SpecialKeywords.TEST_FAILURE_MESSAGE);135 TestNamingUtil.releaseTestInfoByThread();136 return errorMessage;137 }138139 private String skipItem(ITestResult result, Messager messager)140 {141 String test = TestNamingUtil.getCanonicalTestName(result);142143 String errorMessage = getFailureReason(result);144 if (errorMessage.isEmpty())145 {146 // identify is it due to the dependent failure or exception in before suite/class/method147 String[] methods = result.getMethod().getMethodsDependedUpon();148149 // find if any parent method failed/skipped150 boolean dependentMethod = false;151 String dependentMethodName = "";152 for (ITestResult failedTest : result.getTestContext().getFailedTests().getAllResults())153 {154 for (int i = 0; i < methods.length; i++)155 {156 if (methods[i].contains(failedTest.getName()))157 {158 dependentMethodName = failedTest.getName();159 dependentMethod = true;160 break;161 }162 }163 }164165 for (ITestResult skippedTest : result.getTestContext().getSkippedTests().getAllResults())166 {167 for (int i = 0; i < methods.length; i++)168 {169 if (methods[i].contains(skippedTest.getName()))170 {171 dependentMethodName = skippedTest.getName();172 dependentMethod = true;173 break;174 }175 }176 }177178 if (dependentMethod)179 {180 errorMessage = "Test skipped due to the dependency from: " + dependentMethodName;181 } else182 {183 // Try to find error details from last configuration failure in this thread184 TestResultItem resultItem = getConfigFailure();185 if (resultItem != null)186 {187 errorMessage = resultItem.getFailReason();188 }189 }190 }191192 String deviceName = getDeviceName();193194 messager.info(deviceName, test, DateUtils.now(), errorMessage);195196 EmailReportItemCollector197 .push(createTestResult(result, TestResultType.SKIP, errorMessage, result.getMethod().getDescription()));198199 result.getTestContext().removeAttribute(SpecialKeywords.TEST_FAILURE_MESSAGE);200 TestNamingUtil.releaseTestInfoByThread();201 return errorMessage;202 }203 204 private void skipAlreadyPassedItem(ITestResult result, Messager messager)205 {206 String test = TestNamingUtil.getCanonicalTestName(result);207 String deviceName = getDeviceName();208 messager.info(deviceName, test, DateUtils.now());209 }210211 private String getDeviceName()212 {213 String deviceName = DevicePool.getDevice().getName();214 String deviceUdid = DevicePool.getDevice().getUdid();215216 if (!deviceName.isEmpty() && !deviceUdid.isEmpty())217 {218 deviceName = deviceName + " - " + deviceUdid;219 }220221 return deviceName;222 }223 224 private void afterConfiguration(ITestResult result) {225 //register configuration step as test artifact226 String test = TestNamingUtil.getCanonicalTestName(result);227 Artifacts.add("LOG-" + test, ReportContext.getTestLogLink(test));228 Artifacts.add("DEMO-" + test, ReportContext.getTestScreenshotsLink(test));229 TestNamingUtil.releaseTestInfoByThread();230 }231232 @Override233 public void beforeConfiguration(ITestResult result)234 {235 // startItem(result, Messager.CONFIG_STARTED);236 // // do failure test cleanup in this place as right after the test237 // // context doesn't have up-to-date information.238 // // This context cleanup is required to launch dependent steps if parent method pass from Nth retry!239 removeIncorrectlyFailedTests(result.getTestContext());240 241 242 // added 3 below lines to be able to track log/screenshots for before suite/class/method actions too243 TestNamingUtil.releaseTestInfoByThread();244 String test = TestNamingUtil.getCanonicalTestName(result);245 TestNamingUtil.associateCanonicTestName(test);246 247 super.beforeConfiguration(result);248 }249250 @Override251 public void onConfigurationSuccess(ITestResult result)252 {253 afterConfiguration(result);254 // passItem(result, Messager.CONFIG_PASSED);255 super.onConfigurationSuccess(result);256 }257258 @Override259 public void onConfigurationSkip(ITestResult result)260 {261 afterConfiguration(result);262 // skipItem(result, Messager.CONFIG_SKIPPED);263 super.onConfigurationSkip(result);264 }265266 @Override267 public void onConfigurationFailure(ITestResult result)268 {269 afterConfiguration(result); 270 // failItem(result, Messager.CONFIG_FAILED);271 // String test = TestNamingUtil.getCanonicalTestName(result);272 // closeLogAppender(test);273274 String errorMessage = getFailureReason(result);275 takeScreenshot(result, "CONFIGURATION FAILED - " + errorMessage);276 277 TestResultItem resultItem = createTestResult(result, TestResultType.FAIL, errorMessage,278 result.getMethod().getDescription());279 setConfigFailure(resultItem);280281 super.onConfigurationFailure(result);282 }283284 @Override285 public void onStart(ITestContext context)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()305 .containsKey(SpecialKeywords.EXCEL_DS_CUSTOM_PROVIDER) &&306 result.getParameters().length > 0) // set parameters from XLS only if test contains any parameter at307 // all)308 {309 if (result.getTestContext().getCurrentXmlTest().getTestParameters()310 .containsKey(SpecialKeywords.EXCEL_DS_ARGS))311 {312 DSBean dsBean = new DSBean(result.getTestContext());313 int index = 0;314 for (String arg : dsBean.getArgs())315 {316 dsBean.getTestParams().put(arg, (String) result.getParameters()[index++]);317 }318 result.getTestContext().getCurrentXmlTest().setParameters(dsBean.getTestParams());319320 }321 }322 // obligatory reset any registered canonical name because for ALREADY_PASSED methods we can't do this in323 // onTestSkipped method324 TestNamingUtil.releaseTestInfoByThread();325 String test = TestNamingUtil.getCanonicalTestName(result);326 RetryCounter.initCounter(test);327328 startItem(result, Messager.TEST_STARTED);329330 TestNamingUtil.associateCanonicTestName(test);331 }332333 @Override334 public void onTestSuccess(ITestResult result)335 {336 passItem(result, Messager.TEST_PASSED);337338 // TestNamingUtil.releaseTestInfoByThread();339 super.onTestSuccess(result);340 }341342 @Override343 public void onTestFailure(ITestResult result)344 {345 String test = TestNamingUtil.getTestNameByThread();346 347 // String test = TestNamingUtil.getCanonicalTestName(result);348 int count = RetryCounter.getRunCount(test);349 int maxCount = RetryAnalyzer.getMaxRetryCountForTest();350 LOGGER.debug("count: " + count + "; maxCount:" + maxCount);351352 IRetryAnalyzer retry = result.getMethod().getRetryAnalyzer();353 if (count < maxCount && retry == null)354 {355 LOGGER.error("retry_count will be ignored as RetryAnalyzer is not declared for "356 + result.getMethod().getMethodName());357 }358359 if (count < maxCount && retry != null && !Jira.isRetryDisabled(result))360 {361 TestNamingUtil.decreaseRetryCounter(test);362 failRetryItem(result, Messager.RETRY_RETRY_FAILED, count, maxCount);363 } else364 {365 failItem(result, Messager.TEST_FAILED);366 closeLogAppender(test);367 }368369 // TestNamingUtil.releaseTestInfoByThread();370 super.onTestFailure(result);371 }372373 @Override374 public void onTestSkipped(ITestResult result)375 {376 // TODO: improve later removing duplicates with AbstractTest377 // handle Zafira already passed exception for re-run and do nothing. maybe return should be enough378 if (result.getThrowable() != null && result.getThrowable().getMessage() != null379 && result.getThrowable().getMessage().startsWith(SpecialKeywords.ALREADY_PASSED))380 {381 // [VD] it is prohibited to release TestInfoByThread in this place.!382 skipAlreadyPassedItem(result, Messager.TEST_SKIPPED_AS_ALREADY_PASSED);383 return;384 }385386 // handle AbstractTest->SkipExecution387 if (result.getThrowable() != null && result.getThrowable().getMessage() != null388 && result.getThrowable().getMessage().startsWith(SpecialKeywords.SKIP_EXECUTION))389 {390 // [VD] it is prohibited to release TestInfoByThread in this place.!391 return;392 }393394 skipItem(result, Messager.TEST_SKIPPED);395 // TestNamingUtil.releaseTestInfoByThread();396 super.onTestSkipped(result);397 }398399 @Override400 public void onFinish(ITestContext context)401 {402 removeIncorrectlyFailedTests(context);403 // printContextTestsSummary(context);404 super.onFinish(context);405 }406407 /**408 * When the test is restarted this method cleans fail statistics in test context.409 *410 */411 private void removeIncorrectlyFailedTests(ITestContext context)412 {413 // List of test results which we will delete later414 List<ITestResult> testsToBeRemoved = new ArrayList<>();415416 // collect all id's from passed test417 Set<Long> passedTestIds = new HashSet<>();418 for (ITestResult passedTest : context.getPassedTests().getAllResults())419 {420 // adding passed test421 long passedTestId = getMethodId(passedTest);422 LOGGER.debug("Adding passedTest info: " + passedTestId + "; " + passedTest.getName());423 passedTestIds.add(passedTestId);424 }425426 LOGGER.debug("---------------- ANALYZE FAILED RESULTS FOR DUPLICATES -----------------------");427428 Set<Long> failedTestIds = new HashSet<>();429 for (ITestResult failedTest : context.getFailedTests().getAllResults())430 {431432 // id = class + method + dataprovider433 long failedTestId = getMethodId(failedTest);434435 // if we saw this test as a failed test before we mark as to be deleted436 // or delete this failed test if there is at least one passed version437 if (failedTestIds.contains(failedTestId)438 || passedTestIds.contains(failedTestId))439 {440 LOGGER.debug("Test to be removed from context: " + failedTestId + "; " + failedTest.getName());441 testsToBeRemoved.add(failedTest);442 } else443 {444 LOGGER.debug("Test to mark as failed: " + failedTestId + "; " + failedTest.getName());445 failedTestIds.add(failedTestId);446 }447 }448449 LOGGER.debug("---------------- REMOVE DUPLICATES FAILURES -----------------------");450 // finally delete all tests that are marked for removal451 for (Iterator<ITestResult> iterator = context.getFailedTests()452 .getAllResults().iterator(); iterator.hasNext();)453 {454 ITestResult testResult = iterator.next();455 if (testsToBeRemoved.contains(testResult))456 {457 LOGGER.debug("Removing test from context: " + testResult.getName());458 iterator.remove();459 }460 }461 }462463 @SuppressWarnings("unused")464 private void printContextTestsSummary(ITestContext context)465 {466 LOGGER.debug("getAllTestMethods length: " + context.getAllTestMethods().length);467 LOGGER.debug("---------------- PRINT SUMMARIZED SUCCESS -----------------------");468 // print messages about all tests in context469 LOGGER.debug("passed tests size: " + context.getPassedTests().getAllResults().size());470 for (Iterator<ITestResult> iterator = context.getPassedTests()471 .getAllResults().iterator(); iterator.hasNext();)472 {473 ITestResult testResult = iterator.next();474475 long testId = getMethodId(testResult);476 LOGGER.debug("Pass test in context: " + testId + "; "477 + testResult.getName());478 }479480 LOGGER.debug("---------------- PRINT SUMMARIZED FAILURE -----------------------");481 // print messages about all tests in context482 LOGGER.debug("failed tests size: " + context.getFailedTests().getAllResults().size());483 for (Iterator<ITestResult> iterator = context.getFailedTests()484 .getAllResults().iterator(); iterator.hasNext();)485 {486 ITestResult testResult = iterator.next();487488 long testId = getMethodId(testResult);489 LOGGER.debug("Failed test in context: " + testId + "; "490 + testResult.getName());491 }492493 LOGGER.debug("---------------- PRINT SUMMARIZED SKIP -----------------------");494 // print messages about all tests in context495 LOGGER.debug("skipped tests size: " + context.getSkippedTests().getAllResults().size());496 for (Iterator<ITestResult> iterator = context.getSkippedTests()497 .getAllResults().iterator(); iterator.hasNext();)498 {499 ITestResult testResult = iterator.next();500501 long testId = getMethodId(testResult);502 LOGGER.debug("Skipped test in context: " + testId + "; "503 + testResult.getName());504 }505506 LOGGER.debug("---------------- PRINT SUMMARIZED CONFIGURATION SUCCESS -----------------------");507 LOGGER.debug("passed configurations size: " + context.getPassedConfigurations().getAllResults().size());508 for (Iterator<ITestResult> iterator = context.getPassedConfigurations()509 .getAllResults().iterator(); iterator.hasNext();)510 {511 ITestResult testResult = iterator.next();512513 long testId = getMethodId(testResult);514 LOGGER.debug("passed configurations in context: " + testId + "; "515 + testResult.getName());516 }517518 LOGGER.debug("---------------- PRINT SUMMARIZED CONFIGURATION FAILURE -----------------------");519 LOGGER.debug("failed configurations size: " + context.getFailedConfigurations().getAllResults().size());520 for (Iterator<ITestResult> iterator = context.getFailedConfigurations()521 .getAllResults().iterator(); iterator.hasNext();)522 {523 ITestResult testResult = iterator.next();524525 long testId = getMethodId(testResult);526 LOGGER.debug("failed configurations in context: " + testId + "; "527 + testResult.getName());528 }529530 LOGGER.debug("---------------- PRINT SUMMARIZED CONFIGURATION SKIP -----------------------");531 LOGGER.debug("skipped configurations size: " + context.getSkippedConfigurations().getAllResults().size());532 for (Iterator<ITestResult> iterator = context.getSkippedConfigurations()533 .getAllResults().iterator(); iterator.hasNext();)534 {535 ITestResult testResult = iterator.next();536537 long testId = getMethodId(testResult);538 LOGGER.debug("failed configurations in context: " + testId + "; "539 + testResult.getName());540 }541 }542543 private long getMethodId(ITestResult result)544 {545 long id = result.getTestClass().getName().hashCode();546 id = 31 * id + result.getMethod().getMethodName().hashCode();547 id = 31548 * id549 + (result.getParameters() != null ? Arrays.hashCode(result550 .getParameters()) : 0);551 // LOGGER.debug("Calculated id for " + result.getMethod().getMethodName() + " is " + id);552 return id;553 }554555 protected TestResultItem createTestResult(ITestResult result, TestResultType resultType, String failReason,556 String description)557 {558 String group = TestNamingUtil.getPackageName(result);559 String test = TestNamingUtil.getCanonicalTestName(result);560 String linkToLog = ReportContext.getTestLogLink(test);561 String linkToVideo = ReportContext.getTestVideoLink(test);562 // String linkToScreenshots = ReportContext.getTestScreenshotsLink(testName);563 String linkToScreenshots = null;564565 if (TestResultType.FAIL.equals(resultType))566 {567 String bugInfo = Jira.processBug(result);568 if (bugInfo != null)569 {570 if (failReason != null)571 {572 failReason = bugInfo.concat("\n").concat(failReason);573 } else574 {575 failReason = bugInfo;576 }577 }578 }579580 if (!FileUtils.listFiles(ReportContext.getTestDir(test), new String[]581 { "png" }, false).isEmpty())582 {583 if (TestResultType.PASS.equals(resultType) && !Configuration.getBoolean(Parameter.KEEP_ALL_SCREENSHOTS))584 {585 // remove physically all screenshots if test/config pass and KEEP_ALL_SCREENSHOTS=false to improve586 // cooperation with CI tools587 ReportContext.removeTestScreenshots(test);588 } else589 {590 linkToScreenshots = ReportContext.getTestScreenshotsLink(test);591 }592 }593 TestResultItem testResultItem = new TestResultItem(group, test, resultType, linkToScreenshots, linkToLog,594 linkToVideo, failReason);595 testResultItem.setDescription(description);596 // AUTO-1081 eTAF report does not show linked Jira tickets if test PASSED597 // jira tickets should be used for tracking tasks. application issues will be tracked by planned zafira feature598 testResultItem.setJiraTickets(Jira.getTickets(result));599 return testResultItem;600 }601602 protected String getFailureReason(ITestResult result)603 {604 String errorMessage = "";605 String message = "";606607 if (result.getThrowable() != null)608 {609 Throwable thr = result.getThrowable();610 errorMessage = getFullStackTrace(thr);611 message = thr.getMessage();612 result.getTestContext().setAttribute(SpecialKeywords.TEST_FAILURE_MESSAGE, message);613 }614615 return errorMessage;616 }617618 private String getFullStackTrace(Throwable thr)619 {620 String stackTrace = "";621622 if (thr != null)623 {624 stackTrace = thr.getMessage() + "\n";625626 StackTraceElement[] elems = thr.getStackTrace();627 for (StackTraceElement elem : elems)628 {629 stackTrace = stackTrace + "\n" + elem.toString();630 }631 }632 return stackTrace;633 }634635 private void closeLogAppender(String test)636 {637 if (test == null) {638 LOGGER.error("Unable to close appender for null test!");639 return;640 }641 try642 {643 ThreadLogAppender tla = (ThreadLogAppender) Logger.getRootLogger().getAppender("ThreadLogAppender");644 if (tla != null)645 {646 tla.closeResource(test);647 }648 } catch (Throwable e)649 {650 LOGGER.error("close log appender was not successful.");651 e.printStackTrace();652 }653 }654655 private TestResultItem getConfigFailure()656 {657 return configFailures.get();
...
ThreadLogAppender
Using AI Code Generation
1ThreadLogAppender.appendLog("message1");2ThreadLogAppender.appendLog("message2");3ThreadLogAppender.appendLog("message3");4ThreadLogAppender.appendLog("message4");5ThreadLogAppender.appendLog("message5");6ThreadLogAppender.appendLog("message6");7ThreadLogAppender.appendLog("message7");8ThreadLogAppender.appendLog("message8");9ThreadLogAppender.appendLog("message9");10ThreadLogAppender.appendLog("message10");11ThreadLogAppender.appendLog("message11");12ThreadLogAppender.appendLog("message12");13ThreadLogAppender.appendLog("message13");14ThreadLogAppender.appendLog("message14");15ThreadLogAppender.appendLog("message
ThreadLogAppender
Using AI Code Generation
1ThreadLogAppender.add("Test log message");2ThreadLogAppender.add("Test log message", true);3ThreadLogAppender.add("Test log message", false);4ThreadLogAppender.add("Test log message", true, true);5ThreadLogAppender.add("Test log message", false, true);6ThreadLogAppender.add("Test log message", true, false);7ThreadLogAppender.add("Test log message", false, false);8ThreadLogAppender.add("Test log message", true, true, true);9ThreadLogAppender.add("Test log message", false, true, true);10ThreadLogAppender.add("Test log message", true, false, true);11ThreadLogAppender.add("Test log message", false, false, true);12ThreadLogAppender.add("Test log message", true, true, false);13ThreadLogAppender.add("Test log message", false, true, false);
ThreadLogAppender
Using AI Code Generation
1ThreadLogAppender.addThreadLog("ThreadLogAppender is called");2ThreadLogAppender.addThreadLog("ThreadLogAppender is called");3ThreadLogAppender.addThreadLog("ThreadLogAppender is called");4ThreadLogAppender.addThreadLog("ThreadLogAppender is called");5ThreadLogAppender.addThreadLog("ThreadLogAppender is called");6ThreadLogAppender.addThreadLog("ThreadLogAppender is called");7ThreadLogAppender.addThreadLog("ThreadLogAppender is called");8ThreadLogAppender.addThreadLog("ThreadLogAppender is called");9ThreadLogAppender.addThreadLog("ThreadLogAppender is called");10ThreadLogAppender.addThreadLog("ThreadLogAppender is called");11ThreadLogAppender.addThreadLog("ThreadLogAppender is called");12ThreadLogAppender.addThreadLog("ThreadLogAppender is called");13ThreadLogAppender.addThreadLog("ThreadLogAppender is called");
ThreadLogAppender
Using AI Code Generation
1ThreadLogAppender.appendLog("Log message from java code");2ThreadLogAppender.appendLog("Log message from java code", LogLevel.DEBUG);3ThreadLogAppender.appendLog("Log message from java code", LogLevel.INFO);4ThreadLogAppender.appendLog("Log message from java code", LogLevel.WARN);5ThreadLogAppender.appendLog("Log message from java code", LogLevel.ERROR);6ThreadLogAppender.appendLog("Log message from java code", LogLevel.FATAL);7ThreadLogAppender.appendLog("Log message from java code", LogLevel.TRACE);8ThreadLogAppender.appendLog("Log message from java code", LogLevel.ALL);9ThreadLogAppender.appendLog("Log message from java code", LogLevel.OFF);10ThreadLogAppender.appendLog("Log message from java code", LogLevel.OFF, "test");11ThreadLogAppender.appendLog("Log message from java code", LogLevel.OFF, "test");12ThreadLogAppender.appendLog("Log message from java code", LogLevel.OFF, "test", "test");
ThreadLogAppender
Using AI Code Generation
1ThreadLogAppender.addLogger("TestLogger");2Logger logger = ThreadLogAppender.getLogger("TestLogger");3logger.info("Test Message");4ThreadLogAppender.addLogger("TestLogger");5Logger logger = ThreadLogAppender.getLogger("TestLogger");6logger.info("Test Message");7ThreadLogAppender.addLogger("TestLogger");8Logger logger = ThreadLogAppender.getLogger("TestLogger");9logger.info("Test Message");10ThreadLogAppender.addLogger("TestLogger");11Logger logger = ThreadLogAppender.getLogger("TestLogger");12logger.info("Test Message");13ThreadLogAppender.addLogger("TestLogger");14Logger logger = ThreadLogAppender.getLogger("TestLogger");15logger.info("Test Message");16ThreadLogAppender.addLogger("TestLogger");17Logger logger = ThreadLogAppender.getLogger("TestLogger");18logger.info("Test Message");19ThreadLogAppender.addLogger("TestLogger");20Logger logger = ThreadLogAppender.getLogger("TestLogger");21logger.info("Test Message");22ThreadLogAppender.addLogger("TestLogger");23Logger logger = ThreadLogAppender.getLogger("TestLogger");24logger.info("Test Message");25ThreadLogAppender.addLogger("TestLogger");26Logger logger = ThreadLogAppender.getLogger("TestLogger");27logger.info("Test Message");28ThreadLogAppender.addLogger("TestLogger");29Logger logger = ThreadLogAppender.getLogger("TestLogger
ThreadLogAppender
Using AI Code Generation
1ThreadLogAppender.append("ThreadLogAppender.append() method used to write log message");2ThreadLogAppender.append("ThreadLogAppender.append() method used to write log message");3ThreadLogAppender.append("ThreadLogAppender.append() method used to write log message");4ThreadLogAppender.append("ThreadLogAppender.append() method used to write log message");5ThreadLogAppender.append("ThreadLogAppender.append() method used to write log message");6ThreadLogAppender.append("ThreadLogAppender.append() method used to write log message");7ThreadLogAppender.append("ThreadLogAppender.append() method used to write log message");8ThreadLogAppender.append("ThreadLogAppender.append() method used to write log message");9ThreadLogAppender.append("ThreadLogAppender.append() method used to write log message");10ThreadLogAppender.append("ThreadLogAppender.append() method used to write log message");11ThreadLogAppender.append("ThreadLogAppender.append() method used to write log message");12ThreadLogAppender.append("ThreadLogAppender.append() method used
ThreadLogAppender
Using AI Code Generation
1ThreadLogAppender.getInstance().log("ThreadLogAppender message to log file");2ThreadLogAppender.getInstance().log("ThreadLogAppender message to log file");3ThreadLogAppender.getInstance().log("ThreadLogAppender message to log file");4ThreadLogAppender.getInstance().log("ThreadLogAppender message to log file");5ThreadLogAppender.getInstance().log("ThreadLogAppender message to log file");6ThreadLogAppender.getInstance().log("ThreadLogAppender message to log file");7ThreadLogAppender.getInstance().log("ThreadLogAppender message to log file");8ThreadLogAppender.getInstance().log("ThreadLogAppender message to log file");9ThreadLogAppender.getInstance().log("ThreadLogAppender message to log file");10ThreadLogAppender.getInstance().log("ThreadLogAppender message to log file");
ThreadLogAppender
Using AI Code Generation
1ThreadLogAppender.startAppender("1.java");2Logger log = Logger.getLogger("1.java");3log.info("test");4ThreadLogAppender.stopAppender("1.java");5String log = ThreadLogAppender.getLog("1.java");6String log = ThreadLogAppender.getLog("1.java");7String log = ThreadLogAppender.getLog("1.java");8String log = ThreadLogAppender.getLog("1.java");9String log = ThreadLogAppender.getLog("1.java");10String log = ThreadLogAppender.getLog("1.java");11String log = ThreadLogAppender.getLog("1.java");12String log = ThreadLogAppender.getLog("1.java");13String log = ThreadLogAppender.getLog("1.java");14String log = ThreadLogAppender.getLog("1.java");15String log = ThreadLogAppender.getLog("1.java");
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!