Как заставить доступ к текущему JUnitCore добавлять слушателя?

Вы не можете, поскольку нет никаких переменных в Python, но только называет.

, Например:

> a = [1,2,3]
> b = a
> a is b
True

, Какой из тех двух является теперь корректной переменной? Нет никакого различия между a и b.

был подобный вопрос прежде.

6
задан 19 August 2009 в 21:49
поделиться

2 ответа

Не из задачи муравья junit.

Лучше всего написать основной метод, который запускает ваш набор тестов «вручную».

package test;

import org.junit.runner.Request;
import org.junit.runner.Result;
import org.junit.runner.Runner;
import org.junit.runner.notification.RunListener;
import org.junit.runner.notification.RunNotifier;

public class RollYourOwnTestRun {

    public static void main(String[] args) {
        Runner runner = Request.classes(StackTest.class).getRunner();
        RunNotifier notifier = new RunNotifier();
        Result result= new Result();
        RunListener listener= result.createListener();
        notifier.addListener(listener);
        notifier.addListener(...); // add your listener
        notifier.fireTestRunStarted(runner.getDescription());
        runner.run(fNotifier);
        notifier.fireTestRunFinished(result);
    }

}
2
ответ дан 17 December 2019 в 07:07
поделиться

A @RunWith annotation could help (with some minor API best-practice violations): you give your own Runner, and override run(RunNotifier notifier). Through the RunNotifier, you may use the add*Listener-API, which is marked as internal only currently. Good luck!

1
ответ дан 17 December 2019 в 07:07
поделиться
Другие вопросы по тегам:

Похожие вопросы: