Вы не можете, поскольку нет никаких переменных в Python, но только называет.
, Например:
> a = [1,2,3]
> b = a
> a is b
True
, Какой из тех двух является теперь корректной переменной? Нет никакого различия между a
и b
.
был подобный вопрос прежде.
Не из задачи муравья 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);
}
}
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!