Skip to content

Commit 9a0bea5

Browse files
committed
added logger for remove thread id
1 parent 9e7a1f3 commit 9a0bea5

2 files changed

Lines changed: 19 additions & 13 deletions

File tree

src/main/java/com/appium/executor/ATDExecutor.java

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,10 @@ public boolean constructXMLAndTriggerParallelRunner(List<String> test, String pa
5555
if (runnerLevel != null && runnerLevel.equalsIgnoreCase("class")) {
5656
constructXmlSuiteForClassLevelDistributionRunner(test, getTestMethods(setOfMethods),
5757
suiteName, categoryName, deviceCount);
58-
} else if(test!=null && !test.isEmpty()){
59-
constructXmlAndExecuteTestCaseAtRuntime(test, getTestMethods(setOfMethods), suiteName, categoryName, deviceCount);
60-
}else {
58+
} else if (test != null && !test.isEmpty()) {
59+
constructXmlAndExecuteTestCaseAtRuntime(test, getTestMethods(setOfMethods),
60+
suiteName, categoryName, deviceCount);
61+
} else {
6162
constructXmlSuiteForMethodLevelDistributionRunner(test,
6263
getTestMethods(setOfMethods), suiteName, categoryName, deviceCount);
6364
}
@@ -104,8 +105,8 @@ public XmlSuite constructXmlSuiteForParallelRunner(List<String> tests,
104105
}
105106

106107
public XmlSuite constructXmlSuiteForClassLevelDistributionRunner(List<String> tests,
107-
Map<String, List<Method>> methods,
108-
String suiteName, String categoryName, int deviceCount) {
108+
Map<String, List<Method>> methods,
109+
String suiteName, String categoryName, int deviceCount) {
109110
XmlSuite suite = new XmlSuite();
110111
suite.setName(suiteName);
111112
suite.setThreadCount(deviceCount);
@@ -130,8 +131,8 @@ public XmlSuite constructXmlSuiteForClassLevelDistributionRunner(List<String> te
130131

131132

132133
public XmlSuite constructXmlSuiteForMethodLevelDistributionRunner(List<String> tests,
133-
Map<String, List<Method>> methods, String suiteName,
134-
String category, int deviceCount) {
134+
Map<String, List<Method>> methods, String suiteName,
135+
String category, int deviceCount) {
135136
include(groupsInclude, INCLUDE_GROUPS);
136137
XmlSuite suite = new XmlSuite();
137138
suite.setName(suiteName);
@@ -156,8 +157,8 @@ public XmlSuite constructXmlSuiteForMethodLevelDistributionRunner(List<String> t
156157
}
157158

158159
public XmlSuite constructXmlAndExecuteTestCaseAtRuntime(List<String> testCases,
159-
Map<String, List<Method>> methods, String suiteName, String category, int deviceCount) {
160-
160+
Map<String, List<Method>> methods, String suiteName,
161+
String category, int deviceCount) {
161162
List<XmlClass> classes = new ArrayList<>(); // equivalent of <classes> tag
162163
XmlSuite suite = new XmlSuite();
163164
suite.setName(suiteName);
@@ -174,15 +175,15 @@ public XmlSuite constructXmlAndExecuteTestCaseAtRuntime(List<String> testCases,
174175
XmlClass xmlClass = new XmlClass(mapElement.getKey());
175176
List<XmlInclude> includedMethodsList = new ArrayList<>();
176177
for (Method methodName : mapElement.getValue()) {
177-
for(String testCase: testCases){
178+
for (String testCase : testCases) {
178179
if (methodName.getName().equalsIgnoreCase(testCase)) {
179180
XmlInclude includedTestMethod = new XmlInclude(testCase);
180181
includedMethodsList.add(includedTestMethod);
181182
break;
182183
}
183184
}
184185
}
185-
if(!includedMethodsList.isEmpty()) {
186+
if (!includedMethodsList.isEmpty()) {
186187
xmlClass.setIncludedMethods(includedMethodsList);
187188
classes.add(xmlClass);
188189
}
@@ -322,4 +323,4 @@ public CreateGroups invoke() {
322323
return this;
323324
}
324325
}
325-
}
326+
}

src/main/java/com/context/SessionContext.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@ public static synchronized TestExecutionContext getTestExecutionContext(long thr
3939

4040
public static synchronized void remove(long threadId) {
4141
LOGGER.info(String.format("Removing context for thread - %s", threadId));
42-
allTestsExecutionContext.remove(String.valueOf(threadId));
42+
if(allTestsExecutionContext.containsKey(threadId))
43+
allTestsExecutionContext.remove(String.valueOf(threadId));
44+
else
45+
LOGGER.info("Thread Id is not present :"+threadId);
46+
LOGGER.info("remove thread completed for thread id - "+threadId);
47+
4348
}
4449

4550
private static Properties loadReportPortalProperties() {

0 commit comments

Comments
 (0)