Skip to content

Commit

Permalink
Fixing code review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
krmahadevan committed Mar 14, 2024
1 parent 73308ee commit f5123a3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 22 deletions.
13 changes: 7 additions & 6 deletions testng-core/src/main/java/org/testng/TestRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -489,10 +489,10 @@ private void initMethods() {

for (ITestClass tc : m_classMap.values()) {
fixMethodsWithClass(tc.getTestMethods(), tc, testMethods);
fixMethodsWithClass(classLevelConfigs(tc, true), tc, beforeClassMethods);
fixMethodsWithClass(beforeClassConfigMethods(tc), tc, beforeClassMethods);
fixMethodsWithClass(tc.getBeforeTestMethods(), tc, null);
fixMethodsWithClass(tc.getAfterTestMethods(), tc, null);
fixMethodsWithClass(classLevelConfigs(tc, false), tc, afterClassMethods);
fixMethodsWithClass(afterClassConfigMethods(tc), tc, afterClassMethods);
fixMethodsWithClass(tc.getBeforeSuiteMethods(), tc, beforeSuiteMethods);
fixMethodsWithClass(tc.getAfterSuiteMethods(), tc, afterSuiteMethods);
fixMethodsWithClass(tc.getBeforeTestConfigurationMethods(), tc, beforeXmlTestMethods);
Expand Down Expand Up @@ -556,10 +556,11 @@ private void initMethods() {
comparator);
}

private static ITestNGMethod[] classLevelConfigs(ITestClass tc, boolean beforeConfig) {
if (beforeConfig) {
return ITestClassConfigInfo.allBeforeClassMethods(tc).toArray(ITestNGMethod[]::new);
}
private static ITestNGMethod[] beforeClassConfigMethods(ITestClass tc) {
return ITestClassConfigInfo.allBeforeClassMethods(tc).toArray(ITestNGMethod[]::new);
}

private static ITestNGMethod[] afterClassConfigMethods(ITestClass tc) {
return ITestClassConfigInfo.allAfterClassMethods(tc).toArray(ITestNGMethod[]::new);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,9 @@ public interface ITestClassConfigInfo {
*
* @return all before class config methods
*/
default List<ITestNGMethod> getAllBeforeClassMethods() {
return Lists.newArrayList();
}
List<ITestNGMethod> getAllBeforeClassMethods();

default List<ITestNGMethod> getAllAfterClassMethods() {
return Lists.newArrayList();
}
List<ITestNGMethod> getAllAfterClassMethods();

/**
* Query the instance before class methods from config methods map.
Expand Down
20 changes: 10 additions & 10 deletions testng-core/src/main/java/org/testng/internal/NoOpTestClass.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.testng.internal;

import java.util.ArrayList;
import java.util.List;
import org.testng.ITestClass;
import org.testng.ITestNGMethod;
import org.testng.collections.Lists;
import org.testng.xml.XmlClass;
import org.testng.xml.XmlTest;

Expand All @@ -12,17 +12,17 @@ public class NoOpTestClass implements ITestClass, IObject {
protected Class<?> m_testClass = null;

// Test methods
protected List<ITestNGMethod> m_beforeClassMethods = Lists.newArrayList();
protected List<ITestNGMethod> m_beforeTestMethods = Lists.newArrayList();
protected List<ITestNGMethod> m_beforeClassMethods = new ArrayList<>();
protected List<ITestNGMethod> m_beforeTestMethods = new ArrayList<>();
protected ITestNGMethod[] m_testMethods = new ITestNGMethod[0];
protected List<ITestNGMethod> m_afterClassMethods = Lists.newArrayList();
protected List<ITestNGMethod> m_afterTestMethods = Lists.newArrayList();
protected List<ITestNGMethod> m_beforeSuiteMethods = Lists.newArrayList();
protected List<ITestNGMethod> m_afterSuiteMethods = Lists.newArrayList();
protected List<ITestNGMethod> m_beforeTestConfMethods = Lists.newArrayList();
protected List<ITestNGMethod> m_afterTestConfMethods = Lists.newArrayList();
protected List<ITestNGMethod> m_afterClassMethods = new ArrayList<>();
protected List<ITestNGMethod> m_afterTestMethods = new ArrayList<>();
protected List<ITestNGMethod> m_beforeSuiteMethods = new ArrayList<>();
protected List<ITestNGMethod> m_afterSuiteMethods = new ArrayList<>();
protected List<ITestNGMethod> m_beforeTestConfMethods = new ArrayList<>();
protected List<ITestNGMethod> m_afterTestConfMethods = new ArrayList<>();
protected ITestNGMethod[] m_beforeGroupsMethods = new ITestNGMethod[0];
protected List<ITestNGMethod> m_afterGroupsMethods = Lists.newArrayList();
protected List<ITestNGMethod> m_afterGroupsMethods = new ArrayList<>();

private final IdentifiableObject[] m_instances;
private final long[] m_instanceHashes;
Expand Down

0 comments on commit f5123a3

Please sign in to comment.