Advertisement
Guest User

Untitled

a guest
Aug 25th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. package org.jboss.fuse.qa.runner;
  2.  
  3. import org.junit.runner.Description;
  4. import org.junit.runner.Runner;
  5. import org.junit.runner.notification.RunNotifier;
  6.  
  7. import java.lang.reflect.Constructor;
  8.  
  9. import lombok.Getter;
  10.  
  11. public class DynamicRunner extends Runner {
  12.  
  13. @Getter
  14. protected Runner runner;
  15.  
  16. public DynamicRunner(Class<?> clazz) throws Exception {
  17. runner = getRunnerByProperty(clazz);
  18. }
  19.  
  20. @Override
  21. public Description getDescription() {
  22. return runner.getDescription();
  23. }
  24.  
  25. @Override
  26. public void run(RunNotifier notifier) {
  27. runner.run(notifier);
  28. }
  29.  
  30. private Runner getRunnerByProperty(Class<?> testClass) throws Exception {
  31. Class<?> realClass = Class.forName(System.getProperty("arq.runner.class"));
  32. Constructor<?> constructor = realClass.getConstructor(Class.class);
  33. return (Runner) constructor.newInstance(new Object[] {testClass});
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement