org.testng.internal.Utils.log()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(105)

本文整理了Java中org.testng.internal.Utils.log()方法的一些代码示例,展示了Utils.log()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.log()方法的具体详情如下:
包路径:org.testng.internal.Utils
类名称:Utils
方法名:log

Utils.log介绍

[英]Logs the the message to System.out if level is greater than or equal to TestRunner.getVerbose(). The message is logged as:

"[cls] msg"

[中]将消息记录到系统中。如果级别大于或等于TestRunner,则输出。getVerbose()。该消息记录为:

"[cls] msg"

代码示例

代码示例来源:origin: org.testng/testng

public static ParallelMode skipDeprecatedValues(ParallelMode parallel) {
 if (parallel == ParallelMode.TRUE) {
  Utils.log("XmlSuite", 1, "[WARN] 'parallel' value 'true' is deprecated, default value will be used instead: '" + ParallelMode.METHODS + "'.");
  return ParallelMode.METHODS;
 }
 if (parallel == ParallelMode.FALSE) {
  Utils.log("XmlSuite", 1, "[WARN] 'parallel' value 'false' is deprecated, default value will be used instead: '" + ParallelMode.NONE + "'.");
  return ParallelMode.NONE;
 }
 return parallel;
}

代码示例来源:origin: org.testng/testng

private void log(String string) {
 Utils.log("ConfigurationGroupMethods", 2, string);
}

代码示例来源:origin: org.testng/testng

private static void log(int level, String s) {
 Utils.log("TestRunner", level, s);
}

代码示例来源:origin: org.testng/testng

private void log(int level, String s) {
 Utils.log("TestClass", level, s);
}

代码示例来源:origin: org.testng/testng

public static void log(String msg) {
 log("Utils", 2, msg);
}

代码示例来源:origin: org.testng/testng

private static void logClassNotFoundError(String className, Exception ex) {
 Utils.log(CLASS_HELPER, 2, "Could not instantiate " + className
   + " : Class doesn't exist (" + ex.getMessage() + ")");
}

代码示例来源:origin: org.testng/testng

private void log(int level, String s) {
 Utils.log("Invoker " + Thread.currentThread().hashCode(), level, s);
}

代码示例来源:origin: org.testng/testng

private static void checkMethod(Class<?> c, String methodName) {
 Pattern p = Pattern.compile(methodName);
 for (Method m : c.getMethods()) {
  if (p.matcher(m.getName()).matches()) {
   return;
  }
 }
 Utils.log("Warning", 2, "The regular expression \"" + methodName + "\" didn't match any" +
      " method in class " + c.getName());
}

代码示例来源:origin: org.testng/testng

private String getOutputDirectory(XmlSuite xmlSuite) {
 File fileResult = new File(m_outputDirectory + File.separatorChar + xmlSuite.getName()).getAbsoluteFile();
 if (! fileResult.exists()) {
  fileResult.mkdirs();
  if (! fileResult.exists()) {
   Utils.log("Reports", 2, "Problem creating output directory " + fileResult.getAbsolutePath());
  }
 }
 return fileResult.getAbsolutePath();
}

代码示例来源:origin: org.testng/testng

private static void includeOrExcludeClass(String packageName, String className,
  List<String> included, List<String> excluded, List<String> classes)
{
 if (isIncluded(packageName, included, excluded)) {
  Utils.log(PACKAGE_UTILS, 4, "... Including class " + className);
  classes.add(makeFullClassName(packageName, className));
 }
 else {
  Utils.log(PACKAGE_UTILS, 4, "... Excluding class " + className);
 }
}

代码示例来源:origin: org.testng/testng

public void addMethodSelector(IMethodSelector selector, int priority) {
 Utils.log("RunInfo", 3, "Adding method selector: " + selector + " priority: " + priority);
 MethodSelectorDescriptor md = new MethodSelectorDescriptor(selector, priority);
 m_methodSelectors.add(md);
}

代码示例来源:origin: org.testng/testng

@Override
public boolean hasNext() {
 if (index == 0 && !parameters.hasNext() && !hasWarn) {
  hasWarn = true;
  Utils.log("", 2,  "Warning: the data provider '" + dataProviderMethod.getName() + "' returned an empty array or iterator, so this test is not doing anything");
 }
 return parameters.hasNext();
}

代码示例来源:origin: org.testng/testng

private static ConstructorOrMethod getMethod(Test t) {
    String name = null;
    try {
      Method nameMethod = t.getClass().getMethod("getName");
      name = (String) nameMethod.invoke(t);
      return new ConstructorOrMethod(t.getClass().getMethod(name));
    } catch (Throwable th) {
      Utils.log("JUnit3TestMethod", 2,
          "Method '" + name + "' not found in class '" + t + "': " + th.getMessage());
      return null;
    }
  }
}

代码示例来源:origin: org.testng/testng

private void generateReports(List<ISuite> suiteRunners) {
 for (IReporter reporter : m_reporters.values()) {
  try {
   long start = System.currentTimeMillis();
   reporter.generateReport(m_suites, suiteRunners, m_outputDir);
   Utils.log("TestNG", 2, "Time taken by " + reporter + ": "
     + (System.currentTimeMillis() - start) + " ms");
  }
  catch(Exception ex) {
   System.err.println("[TestNG] Reporter " + reporter + " failed");
   ex.printStackTrace(System.err);
  }
 }
}

代码示例来源:origin: org.testng/testng

/**
 * Using reflection to remain Java 5 compliant.
 */
private void addServiceLoaderListeners() {
  Iterable<ITestNGListener> loader = m_serviceLoaderClassLoader != null ?
    ServiceLoader.load(ITestNGListener.class, m_serviceLoaderClassLoader)
    : ServiceLoader.load(ITestNGListener.class);
  for (ITestNGListener l : loader) {
   Utils.log("[TestNG]", 2, "Adding ServiceLoader listener:" + l);
   addListener(l);
   addServiceLoaderListener(l);
  }
}

代码示例来源:origin: org.testng/testng

@Override
  public void run() {
   Utils.log("[SuiteWorker]", 4, "Running XML Test '"
        +  testRunner.getTest().getName() + "' in Parallel");
   runTest(testRunner);
  }
}

代码示例来源:origin: org.testng/testng

List<XmlSuite> extractSuitesFrom(File jarFile) {
  try {
    Utils.log("TestNG", 2, "Trying to open jar file:" + jarFile);
    List<String> classes = Lists.newArrayList();
    boolean foundTestngXml = testngXmlExistsInJar(jarFile, classes);
    if (!foundTestngXml) {
      Utils.log("TestNG", 1,
          "Couldn't find the " + xmlPathInJar + " in the jar file, running all the classes");
      suites.add(XmlSuiteUtils.newXmlSuiteUsing(classes));
    }
  } catch (IOException ex) {
    throw new TestNGException(ex);
  }
  return suites;
}

代码示例来源:origin: org.testng/testng

private List<XmlClass> initializeXmlClasses() {
 List<XmlClass> result= Lists.newArrayList();
 try {
  String[] classes = PackageUtils.findClassesInPackage(m_name, m_include, m_exclude);
  int index = 0;
  for(String className: classes) {
   result.add(new XmlClass(className, index++, false /* don't load classes */));
  }
 }
 catch(IOException ioex) {
  Utils.log("XmlPackage", 1, ioex.getMessage());
 }
 return result;
}

代码示例来源:origin: org.testng/testng

public ClassInfoMap(List<XmlClass> classes, boolean includeNested) {
 includeNestedClasses = includeNested;
 for (XmlClass xmlClass : classes) {
  try {
   Class<?> c = xmlClass.getSupportClass();
   registerClass(c, xmlClass);
  } catch (NoClassDefFoundError e) {
   Utils.log("[ClassInfoMap]", 1, "Unable to open class " + xmlClass.getName()
     + " - unable to resolve class reference " + e.getMessage());
   if (xmlClass.loadClasses()) {
    throw e;
   }
  }
 }
}

代码示例来源:origin: org.testng/testng

private void resetContext(Interpreter interpreter) {
 try {
  interpreter.unset("method");
  interpreter.unset("groups");
  interpreter.unset("testngMethod");
 }
 catch(EvalError evalError) {
  Utils.log("bsh.Interpreter", 2, "Cannot reset interpreter:" + evalError.getMessage());
 }
}

相关文章