Using multiple runner annotation in test class for spring-boot and testrail

399 views Asked by At

I have to link my tests with testrail and for that I have to use the testrailrunner. But if I exclude the springjunit runner then my tests fail on starting the service and its not possible to use both the runners

What's a workaround for this so that my tests get inititalize with the service beans and still logg in test rail?

1

There are 1 answers

0
Maciej Walkowiak On BEST ANSWER

There is no way to have multiple test runners on single unit test, but use can use JUnit rules instead.

Spring introduces support for @Rules in 4.2 (4.2 RC1 is the latest version): https://jira.spring.io/browse/SPR-7731

I am not familiar with testrailrunner, but if it has no support for JUnit rules, you can:

  • implement custom rule for handling testrail
  • implement your own runner that handles functionality from SpringJUnit4ClassRunner and testrailrunner
  • implement custom rule for injecting Spring context - there are some implementations that are supposed to work with current Spring version: http://www.alexecollins.com/tutorial-junit-rule/ (I haven't tested it).