Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arquillian as JUnit rule instead of runner #107

Conversation

ahus1
Copy link
Contributor

@ahus1 ahus1 commented Jun 16, 2016

I'm working in an environment where I run my JUnit test suite using a spring runner. But I still wanted to use Graphene/Arquillian to test my frontends (https://github.com/dukecon/dukecon_server/blob/develop/impl/src/test/java/org/dukecon/server/gui/AbstractPageTest.java)

Therefore I've extracted the essential functionality of the Arquillian Runner into two JUnit rules: ArquillianClassRule and ArquillianRule. I wonder if you consider this a useful contribution to the Arquillian project.

Looking at the JUnitIntegrationWithRuleTestCase and the FIXME elements the rules behave a little bit different than the runner when it comes to test suites and custom lifecycles.

Hits what needs to be added, moved or removed are welcome. This PR is in work-in-progress state.

Thanks
Alexander

@lordofthejars
Copy link
Member

@bartoszmajsak maybe we can move these pieces into a new module and release as experimental module? cc/ @aslakknutsen

@bartoszmajsak
Copy link
Member

That's cool stuff @ahus1. I will take time next week to review and we see how we can proceed further.

Many thanks for your contribution!

@bartoszmajsak bartoszmajsak self-assigned this Dec 22, 2016
@hschoefer
Copy link

Any updates for this Pull Request?

@bartoszmajsak
Copy link
Member

bartoszmajsak commented Dec 5, 2017

Try it out with extensions:

  • Graphene
  • Drone
  • Cube (standalone mode)

to figure out if it works and if there is any missing we should implement/add to this PR.

Note: Downside of using this Rule is that it will execute e.g. cube-container logic per each test class rather than the whole suite.

@dipak-pawar
Copy link
Contributor

Findings for Rule & Arquillian Rule:
Drone: Tried few examples of drone from example test:

public class DoubleDroneInjectionTestCase {

    @ClassRule
    public static ArquillianClassRule classRule = new ArquillianClassRule();

    @Rule
    public ArquillianRule rule = new ArquillianRule();
    
    @Test
    public void doubleMethodWebDrivers(@Drone WebDriver webdriver1, @Drone WebDriver webdriver2) {

        Assert.assertNotNull("Class scoped webdriver1 was instantiated", this.webdriver1);
        Assert.assertNotNull("Class scoped webdriver2 was instantiated", this.webdriver2);
        Assert.assertNotNull("Method scoped webdriver1 was instantiated", webdriver1);
        Assert.assertNotNull("Method scoped webdriver2 was instantiated", webdriver2);
    }

Getting validation error Method doubleMethodWebDrivers should have no parameters. So this means we can't inject method scoped drone instance
using parameter to method doubleMethodWebDrivers(@Drone WebDriver webdriver1, @Drone WebDriver webdriver2). Becuase while running it with BlockJUnit4ClassRunner
it validates method has any args - https://github.com/junit-team/junit4/blob/master/src/main/java/org/junit/runners/ParentRunner.java#L170,
where in arquillian we have our own implementation. https://github.com/arquillian/arquillian-core/blob/master/junit/core/src/main/java/org/jboss/arquillian/junit/Arquillian.java#L148
We need to address this.

@bartoszmajsak
Copy link
Member

bartoszmajsak commented Dec 20, 2017

Upstream 1bc6804. Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants