12859841981e9d88b24e94ef89fbcc5c18d7c49a
2 * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir <alexmonthy@efficios.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 package org
.lttng
.ust
.agent
.utils
;
21 import org
.junit
.runner
.Description
;
22 import org
.junit
.runner
.notification
.Failure
;
23 import org
.junit
.runner
.notification
.RunListener
;
24 import org
.junit
.runner
.notification
.RunNotifier
;
25 import org
.junit
.runners
.BlockJUnit4ClassRunner
;
26 import org
.junit
.runners
.model
.InitializationError
;
29 * Test runner that will print the name of the test being run to stdout.
31 * Thanks to http://stackoverflow.com/a/27070843/4227853 for the tips.
33 * @author Alexandre Montplaisir
35 public class TestPrintRunner
extends BlockJUnit4ClassRunner
{
41 * @throws InitializationError
43 public TestPrintRunner(Class
<?
> klass
) throws InitializationError
{
48 public void run(RunNotifier notifier
) {
49 RunListener listener
= new TestPrintListener();
51 notifier
.addListener(listener
);
53 notifier
.removeListener(listener
);
57 * Listener that will print the class and test name to stdout.
59 public static class TestPrintListener
extends RunListener
{
62 public void testStarted(Description description
) {
63 System
.out
.println("Running " + getTestName(description
));
67 public void testAssumptionFailure(Failure failure
) {
68 System
.out
.println("SKIPPING TEST: " + getTestName(failure
.getDescription()));
69 System
.out
.println(failure
.getMessage());
73 * Get the className#methodName from a Description.
75 private static String
getTestName(Description description
) {
76 return description
.getClassName() + '#' + description
.getMethodName();
This page took 0.032659 seconds and 4 git commands to generate.