private static boolean isTooVerbose() { return Boolean.getBoolean(TestNG.SHOW_TESTNG_STACK_FRAMES) || TestRunner.getVerbose() >= 2; }
private void dumpInvokedMethods() { MethodHelper.dumpInvokedMethodsInfoToConsole(m_invokedMethods, getVerbose()); }
/** * @deprecated Unused */ @Deprecated public static void logInvocation(String reason, Method thisMethod, Object[] parameters) { String clsName = thisMethod.getDeclaringClass().getName(); int n = clsName.lastIndexOf('.'); if (n >= 0) { clsName = clsName.substring(n + 1); } String methodName = clsName + '.' + thisMethod.getName(); if (TestRunner.getVerbose() >= 2) { StringBuilder paramString = new StringBuilder(); if (parameters != null) { for (Object p : parameters) { paramString.append(p.toString()).append(' '); } } log("", 2, "Invoking " + reason + methodName + '(' + paramString + ')'); } }
private static boolean isTooVerbose() { return RuntimeBehavior.showTestNGStackFrames() || TestRunner.getVerbose() >= 2; }
private void dumpInvokedMethods() { MethodHelper.dumpInvokedMethodsInfoToConsole(m_invokedMethods, getVerbose()); }
/** @deprecated Unused */ @Deprecated public static void logInvocation(String reason, Method thisMethod, Object[] parameters) { String clsName = thisMethod.getDeclaringClass().getName(); int n = clsName.lastIndexOf('.'); if (n >= 0) { clsName = clsName.substring(n + 1); } String methodName = clsName + '.' + thisMethod.getName(); if (TestRunner.getVerbose() >= 2) { StringBuilder paramString = new StringBuilder(); if (parameters != null) { for (Object p : parameters) { paramString.append(p.toString()).append(' '); } } log("", 2, "Invoking " + reason + methodName + '(' + paramString + ')'); } }
/** * Log the passed string to the HTML reports if the current verbosity * is equal or greater than the one passed in parameter * * @param s The message to log * @param level The verbosity of this message */ public static void log(String s, int level) { if (TestRunner.getVerbose() >= level) { log(s, getCurrentTestResult()); } }
/** * Log the passed string to the HTML reports if the current verbosity * is equal or greater than the one passed in parameter. If logToStandardOut * is true, the string will also be printed on standard out. * * @param s The message to log * @param level The verbosity of this message * @param logToStandardOut Whether to print this string on standard * out too */ public static void log(String s, int level, boolean logToStandardOut) { if (TestRunner.getVerbose() >= level) { log(s, getCurrentTestResult()); if (logToStandardOut) { System.out.println(s); } } }
/** * Logs the the message to System.out if level is greater than * or equal to TestRunner.getVerbose(). The message is logged as: * <pre> * "[cls] msg" * </pre> * * @param cls the class name to prefix the log message. * @param level the logging level of the message. * @param msg the message to log to System.out. */ public static void log(String cls, int level, String msg) { // Why this coupling on a static member of TestRunner.getVerbose()? if (TestRunner.getVerbose() >= level) { if (cls.length() > 0) { LOG.info("[" + cls + "] " + msg); } else { LOG.info(msg); } } }
/** * Log the passed string to the HTML reports if the current verbosity is equal to or greater than the * one passed as a parameter. * * @param s The message to log * @param level The verbosity of this message */ public static void log(String s, int level) { if (TestRunner.getVerbose() >= level) { log(s, getCurrentTestResult()); } }
private static void writeFile(File outputFile, String sb, @Nullable String encoding) { BufferedWriter fw = null; try { fw = openWriter(outputFile, encoding); fw.write(sb); Utils.log("", 3, "Creating " + outputFile.getAbsolutePath()); } catch(IOException ex) { if (TestRunner.getVerbose() > 1) { LOG.error("ERROR WHILE WRITING TO " + outputFile,ex); } else { log(FORMAT, 1, "Error while writing to " + outputFile + ": " + ex.getMessage()); } } finally { try { if (fw != null) { fw.close(); } } catch (IOException e) { // ignore } } }
/** * Log the passed string to the HTML reports if the current verbosity is equal to or greater than the * one passed as a parameter. If logToStandardOut is true, the string will also be printed on * standard out. * * @param s The message to log * @param level The verbosity of this message * @param logToStandardOut Whether to print this string on standard out too */ public static void log(String s, int level, boolean logToStandardOut) { if (TestRunner.getVerbose() >= level) { log(s, getCurrentTestResult()); if (logToStandardOut) { System.out.println(s); } } }
if (TestRunner.getVerbose() > 1) { LOG.error(e.getMessage(),e);
private static void writeFile(File outputFile, String sb, @Nullable String encoding) { try (BufferedWriter fw = openWriter(outputFile, encoding)) { fw.write(sb); Utils.log("", 3, "Creating " + outputFile.getAbsolutePath()); } catch (IOException ex) { if (TestRunner.getVerbose() > 1) { LOG.error("ERROR WHILE WRITING TO " + outputFile, ex); } else { log(FORMAT, 1, "Error while writing to " + outputFile + ": " + ex.getMessage()); } } // ignore }
/** * Logs the beginning of the {@link #beforeRun()} . */ private void logStart() { log(3, "Running test " + m_testName + " on " + m_classMap.size() + " " + " classes, " + " included groups:[" + Strings.valueOf(m_xmlMethodSelector.getIncludedGroups()) + "] excluded groups:[" + Strings.valueOf(m_xmlMethodSelector.getExcludedGroups()) + "]"); if (getVerbose() >= 3) { for (ITestClass tc : m_classMap.values()) { ((TestClass) tc).dump(); } } }
/** Logs the beginning of the {@link #beforeRun()} . */ private void logStart() { log( 3, "Running test " + m_testName + " on " + m_classMap.size() + " " + " classes, " + " included groups:[" + Strings.valueOf(m_xmlMethodSelector.getIncludedGroups()) + "] excluded groups:[" + Strings.valueOf(m_xmlMethodSelector.getExcludedGroups()) + "]"); if (getVerbose() >= 3) { for (ITestClass tc : m_classMap.values()) { ((TestClass) tc).dump(); } } }
/** * Run TestNG. */ public void run() { initializeEverything(); sanityCheck(); runExecutionListeners(true /* start */); runSuiteAlterationListeners(); m_start = System.currentTimeMillis(); List<ISuite> suiteRunners = runSuites(); m_end = System.currentTimeMillis(); if(null != suiteRunners) { generateReports(suiteRunners); } runExecutionListeners(false /* finish */); exitCode = this.exitCodeListener.getStatus(); if(!exitCodeListener.hasTests()) { if (TestRunner.getVerbose() > 1) { System.err.println("[TestNG] No tests found. Nothing was run"); usage(); } } m_instance = null; m_jCommander = null; }
@Override public TestRunner newTestRunner(ISuite suite, XmlTest test, Collection<IInvokedMethodListener> listeners, List<IClassListener> classListeners, Map<Class<? extends IDataProviderListener>,IDataProviderListener> dataProviderListeners) { TestRunner testRunner; if (target instanceof ITestRunnerFactory2) { testRunner = ((ITestRunnerFactory2)target).newTestRunner(suite, test, listeners, classListeners, dataProviderListeners); } else { testRunner = target.newTestRunner(suite, test, listeners, classListeners); } testRunner.addListener(new TextReporter(testRunner.getName(), TestRunner.getVerbose())); for (ITestListener itl : failureGenerators) { testRunner.addListener(itl); } return testRunner; } }
if (TestRunner.getVerbose() > 1) { ex.printStackTrace(System.out);
@Override public TestRunner newTestRunner(ISuite suite, XmlTest test, Collection<IInvokedMethodListener> listeners, List<IClassListener> classListeners, Map<Class<? extends IDataProviderListener>, IDataProviderListener> dataProviderListeners) { boolean skip = skipFailedInvocationCounts; if (! skip) { skip = test.skipFailedInvocationCounts(); } TestRunner testRunner = new TestRunner(configuration, suite, test, suite.getOutputDirectory(), suite.getAnnotationFinder(), skip, listeners, classListeners, comparator, dataProviderListeners); if (useDefaultListeners) { testRunner.addListener(new TestHTMLReporter()); testRunner.addListener(new JUnitXMLReporter()); //TODO: Moved these here because maven2 has output reporters running //already, the output from these causes directories to be created with //files. This is not the desired behaviour of running tests in maven2. //Don't know what to do about this though, are people relying on these //to be added even with defaultListeners set to false? testRunner.addListener(new TextReporter(testRunner.getName(), TestRunner.getVerbose())); } for (ITestListener itl : failureGenerators) { testRunner.addTestListener(itl); } for (IConfigurationListener cl : configuration.getConfigurationListeners()) { testRunner.addConfigurationListener(cl); } return testRunner; } }