+1

regards,
gerhard



2015-10-07 20:16 GMT+02:00 Rafael Pestano <[email protected]>:

> Hi Romain,
>
> That would be great!
>
> Em qua, 7 de out de 2015 15:11, Romain Manni-Bucau <[email protected]>
> escreveu:
>
> > Hi Rafael,
> >
> > I would rather contribute an integration to cucumber. AFAIK they have a
> > weld and openejb integration for CDI but no openwebbeans/DS.
> >
> >
> >
> > Romain Manni-Bucau
> > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > <http://rmannibucau.wordpress.com> | Github <
> > https://github.com/rmannibucau> |
> > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > <http://www.tomitribe.com>
> >
> > 2015-10-07 20:03 GMT+02:00 Rafael Pestano <[email protected]>:
> >
> > > Hi guys,
> > >
> > > I've pushed the cucumber runner for deltaspike here:
> > >
> > >
> >
> https://github.com/rmpestano/deltaspike/blob/master/deltaspike/modules/test-control/api/src/main/java/org/apache/deltaspike/testcontrol/api/cucumber/CdiCucumberTestRunner.java
> > >
> > >
> > > I have implemented some simple tests here:
> > >
> > >
> >
> https://github.com/rmpestano/deltaspike/tree/master/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc014
> > >
> > > Things to note:
> > >
> > > - With a dedicated runner there is no need to create a fake @Test I
> > > commented in this thread;
> > > - CDI container is started for every feature. See this step
> > > <
> > >
> >
> https://github.com/rmpestano/deltaspike/blob/master/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc014/feature/multiscenario/AppScopeBeanSteps2.java#L41
> > > >
> > > which uses the same bean in different features
> > > <
> > >
> >
> https://github.com/rmpestano/deltaspike/blob/master/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc014/feature/multiscenario/AppScopeBeanFeatureTest.java#L38
> > > >
> > > ;
> > > - CDI container is reused across scenarios see this step;
> > > <
> > >
> >
> https://github.com/rmpestano/deltaspike/blob/master/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc014/feature/multiscenario/AppScopeBeanSteps.java#L65
> > > >
> > > - I have duplicated a lot of code from CdiTestRunner, if this solution
> is
> > > going to be accepted we need to make some refactory
> > > - Didn't implemented @Suite of features
> > >
> > >
> > > WDYT?
> > >
> > > 2015-10-05 22:44 GMT-03:00 Rafael Pestano <[email protected]>:
> > >
> > > > Hi Daniel,
> > > >
> > > > Yes, I also think a dedicated runner is the best approach, I'll work
> on
> > > it
> > > > during the week and let you know when I have some progress and/or
> > issues
> > > ;)
> > > >
> > > >
> > > >
> > > > 2015-10-05 21:38 GMT-03:00 Daniel Cunha <[email protected]>:
> > > >
> > > >> @Rafael,
> > > >>
> > > >> I didn't like your idea to change CdiTestRunner.
> > > >> Do we can change API to extend it and create another runner with
> > > >> Cumcumber?
> > > >> (Something like: CdiCumcumberTestRunner)
> > > >>
> > > >> Please, open a discuss in dev's mail list[1] about it. It seem cool
> > > >> feature.
> > > >>
> > > >> Thank you!
> > > >>
> > > >> [1] http://deltaspike.apache.org/community.html#Mailinglists
> > > >>
> > > >>
> > > >> On Mon, Oct 5, 2015 at 5:17 PM, Jason Porter <
> [email protected]
> > >
> > > >> wrote:
> > > >>
> > > >> > Ah, I see. No, there is no way to do that, JUnit only allows one
> > > runner.
> > > >> >
> > > >> > On Mon, Oct 5, 2015 at 2:14 PM, Rafael Pestano <
> [email protected]
> > >
> > > >> > wrote:
> > > >> >
> > > >> > > Hi Jason,
> > > >> > >
> > > >> > >
> > > >> > > The idea is to enable Cucumber in TestControl based tests and
> not
> > in
> > > >> > > current Deltaspike tests.
> > > >> > >
> > > >> > > Currently we cannot (let me know if there is a way) run a
> > > TestControl
> > > >> > test
> > > >> > > and use cucumber at the same time because both have its own
> > runners,
> > > >> > right?
> > > >> > >
> > > >> > >
> > > >> > >
> > > >> > > 2015-10-05 17:10 GMT-03:00 Jason Porter <
> [email protected]
> > >:
> > > >> > >
> > > >> > > > While I like cucumber and I think it does a good job at
> helping
> > > >> tests
> > > >> > be
> > > >> > > > easy to read, I think we'd need a compelling reason to start
> > using
> > > >> it /
> > > >> > > > migrating tests.
> > > >> > > >
> > > >> > > > On Mon, Oct 5, 2015 at 2:06 PM, Rafael Pestano <
> > > [email protected]
> > > >> >
> > > >> > > > wrote:
> > > >> > > >
> > > >> > > > > Hi guys,
> > > >> > > > >
> > > >> > > > > I recently made a small PoC in TestControl module to enable
> > > >> cucumber
> > > >> > > > tests
> > > >> > > > > using deltapike,  here's an example:
> > > >> > > > >
> > > >> > > > >
> > > >> > > > > @RunWith(CdiTestRunner.class)
> > > >> > > > > @CucumberOptions(
> > > >> > > > >     features = "src/test/resources/features/uc014.feature"
> > > >> > > > > )
> > > >> > > > > public class CucumberCDITest
> > > >> > > > > {
> > > >> > > > >
> > > >> > > > >
> > > >> > > > >     @Test
> > > >> > > > >     public void fakeIt() //needed by junit runner
> > > >> > > > >     {
> > > >> > > > >
> > > >> > > > >     }
> > > >> > > > >
> > > >> > > > >
> > > >> > > > > }
> > > >> > > > >
> > > >> > > > >
> > > >> > > > > uc014.feature
> > > >> > > > >
> > > >> > > > > Feature: ApplicationScoped bean test
> > > >> > > > >   As a user of DeltaSpike Test Control module
> > > >> > > > >   I want to inject application scoped beans
> > > >> > > > >   So that I can test application scoped beans
> > > >> > > > >
> > > >> > > > >
> > > >> > > > >   Scenario Outline: bean increment
> > > >> > > > >     Given test bean value is set to <value>
> > > >> > > > >     When bean value is incremented by 2
> > > >> > > > >     Then bean value should be <result>
> > > >> > > > >
> > > >> > > > >   Examples: examples1
> > > >> > > > >   | value | result |
> > > >> > > > >   | 1     | 3      |
> > > >> > > > >   | 0     | 2      |
> > > >> > > > >   | 10    | 12     |
> > > >> > > > >
> > > >> > > > >
> > > >> > > > > public class Uc014Steps
> > > >> > > > > <
> > > >> > > > >
> > > >> > > >
> > > >> > >
> > > >> >
> > > >>
> > >
> >
> https://github.com/rmpestano/deltaspike/blob/master/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc014/Uc014Steps.java
> > > >> > > > > >
> > > >> > > > > {
> > > >> > > > >
> > > >> > > > >   @Inject
> > > >> > > > >   private ApplicationScopedTestBean testBean;
> > > >> > > > >
> > > >> > > > >   @Inject
> > > >> > > > >   private ApplicationScopedTestBeanClient testBeanClient;
> > > >> > > > >
> > > >> > > > >
> > > >> > > > >   @Given("^test bean value is set to (\\d+)$")
> > > >> > > > >   public void initBeanValue(int value) {
> > > >> > > > >     this.testBean.setValue(value);
> > > >> > > > >   }
> > > >> > > > >
> > > >> > > > >   @When("^bean value is incremented by (\\d+)$")
> > > >> > > > >   public void incrementBeanValue(int amount) {
> > > >> > > > >     this.testBeanClient.increment(amount);//will increment
> > bean
> > > >> value
> > > >> > > > >   }
> > > >> > > > >
> > > >> > > > >   @Then("^bean value should be (\\d+)$")
> > > >> > > > >   public void checkBeanValue(int result) {
> > > >> > > > >     Assert.assertEquals(result, this.testBean.getValue());
> > > >> > > > >   }
> > > >> > > > >
> > > >> > > > >   @After
> > > >> > > > >   public void finalCheck() {
> > > >> > > > >     int value =
> > > >> > > > >
> > > >> > > > >
> > > >> > > >
> > > >> > >
> > > >> >
> > > >>
> > >
> >
> BeanProvider.getContextualReference(ApplicationScopedTestBean.class).getValue();
> > > >> > > > >     int nextValue =
> > > >> > > > >
> > > >> > > > >
> > > >> > > >
> > > >> > >
> > > >> >
> > > >>
> > >
> >
> BeanProvider.getContextualReference(ApplicationScopedTestBeanClient.class).getNextValue();
> > > >> > > > >
> > > >> > > > >     if (value == 0)
> > > >> > > > >     {
> > > >> > > > >       throw new IllegalStateException("new
> application-scoped
> > > bean
> > > >> > > > > instance was created");
> > > >> > > > >     }
> > > >> > > > >
> > > >> > > > >     if (nextValue == 1)
> > > >> > > > >     {
> > > >> > > > >       throw new IllegalStateException("new
> application-scoped
> > > bean
> > > >> > > > > instance was created");
> > > >> > > > >     }
> > > >> > > > >   }
> > > >> > > > >
> > > >> > > > >
> > > >> > > > > }
> > > >> > > > >
> > > >> > > > > It is working here: https://github.com/rmpestano/deltaspike
> > > >> > > > > <https://github.com/rmpestano/deltaspike> and the changes
> > I've
> > > >> made
> > > >> > > are
> > > >> > > > > in this
> > > >> > > > > commit
> > > >> > > > > <
> > > >> > > > >
> > > >> > > >
> > > >> > >
> > > >> >
> > > >>
> > >
> >
> https://github.com/rmpestano/deltaspike/commit/53a91c4a592afb084c42df6ff023bfc4f1b325f8
> > > >> > > > > >
> > > >> > > > > .
> > > >> > > > >
> > > >> > > > >
> > > >> > > > > I did not created another runner, for simplicity i'm running
> > > >> cucumber
> > > >> > > > > inside CdiTestRunner, here's relevant bits:
> > > >> > > > >
> > > >> > > > > @Override
> > > >> > > > > public void run(RunNotifier runNotifier){
> > > >> > > > >
> > > >> > > > > if
> > > >> > > > >
> > > >> > > >
> > > >> > >
> > > >> >
> > > >>
> > >
> >
> (getTestClass().getJavaClass().isAnnotationPresent(CucumberOptions.class))
> > > >> > > > > {
> > > >> > > > >
> > > >> > > > >    testContext.runCucumber(runNotifier,getTestClass());
> > > >> > > > >
> > > >> > > > > }
> > > >> > > > >
> > > >> > > > > else
> > > >> > > > >
> > > >> > > > > {
> > > >> > > > >     super.run(runNotifier);
> > > >> > > > > }
> > > >> > > > >
> > > >> > > > > public void runCucumber(RunNotifier runNotifier, TestClass
> > > >> testClass)
> > > >> > > > > throws IOException, InitializationError
> > > >> > > > > {
> > > >> > > > >     applyBeforeClassConfig(testClass.getJavaClass());
> > > >> > > > >     new Cucumber(testClass.getJavaClass()).run(runNotifier);
> > > >> > > > >     applyAfterClassConfig();
> > > >> > > > > }
> > > >> > > > >
> > > >> > > > >
> > > >> > > > > I also needed to create an object factory
> > > >> > > > > <
> > > >> > > > >
> > > >> > > >
> > > >> > >
> > > >> >
> > > >>
> > >
> >
> https://github.com/rmpestano/deltaspike/blob/master/deltaspike/modules/test-control/impl/src/main/java/cucumber/runtime/CucumberObjectFactory.java
> > > >> > > > > >
> > > >> > > > > in order to make step definitions (like Uc014Steps) CDI
> beans.
> > > >> This
> > > >> > > > factory
> > > >> > > > > must be in package 'cucumber.runtime' otherwise Cucumber
> wont
> > > use
> > > >> it
> > > >> > (I
> > > >> > > > > think there is way to make cucumber load it from other
> > packages
> > > >> but
> > > >> > we
> > > >> > > > need
> > > >> > > > > to create a cucumber backend for it)
> > > >> > > > >
> > > >> > > > >
> > > >> > > > >
> > > >> > > > >
> > > >> > > > > Do you think this could be incorporated in Test Control
> > module?
> > > >> > > > >
> > > >> > > > >
> > > >> > > > > If you have interest I think we need to create a separated
> > > runner
> > > >> and
> > > >> > > > then
> > > >> > > > > we can get ride of the
> > > >> > > > >
> > > >> > > > >     @Test
> > > >> > > > >     public void fakeIt() //needed by junit runner
> > > >> > > > >     {
> > > >> > > > >
> > > >> > > > >     }
> > > >> > > > >
> > > >> > > > > without the fake test junit runner will complain cause there
> > is
> > > no
> > > >> > test
> > > >> > > > > method.
> > > >> > > > >
> > > >> > > > >
> > > >> > > > > OBS:
> > > >> > > > > I needed to declare sure-fire plugin to use a newer version
> > > >> > > > > I had to upgrade junit to 4.11 because cucumber-junit
> depends
> > on
> > > >> it
> > > >> > > > >
> > > >> > > > > --
> > > >> > > > > <http://www.advancedit.com.br/>Att,
> > > >> > > > >
> > > >> > > > > Rafael M. Pestano
> > > >> > > > >
> > > >> > > > > Desenvolvedor Java Cia. de Processamento de Dados do Rio
> > Grande
> > > do
> > > >> > Sul
> > > >> > > > > http://rpestano.wordpress.com/
> > > >> > > > > @realpestano <https://twitter.com/realpestano>
> > > >> > > > >
> > > >> > > >
> > > >> > > >
> > > >> > > >
> > > >> > > > --
> > > >> > > > Jason Porter
> > > >> > > > http://en.gravatar.com/lightguardjp
> > > >> > > >
> > > >> > >
> > > >> > >
> > > >> > >
> > > >> > > --
> > > >> > > <http://www.advancedit.com.br/>Att,
> > > >> > >
> > > >> > > Rafael M. Pestano
> > > >> > >
> > > >> > > Desenvolvedor Java Cia. de Processamento de Dados do Rio Grande
> do
> > > Sul
> > > >> > > http://rpestano.wordpress.com/
> > > >> > > @realpestano <https://twitter.com/realpestano>
> > > >> > >
> > > >> >
> > > >> >
> > > >> >
> > > >> > --
> > > >> > Jason Porter
> > > >> > http://en.gravatar.com/lightguardjp
> > > >> >
> > > >>
> > > >>
> > > >>
> > > >> --
> > > >> Daniel Cunha (soro)
> > > >> https://twitter.com/dvlc_
> > > >> http://www.tomitribe.com
> > > >>
> > > >
> > > >
> > > >
> > > > --
> > > > <http://www.advancedit.com.br/>Att,
> > > >
> > > > Rafael M. Pestano
> > > >
> > > > Desenvolvedor Java Cia. de Processamento de Dados do Rio Grande do
> Sul
> > > > http://rpestano.wordpress.com/
> > > > @realpestano <https://twitter.com/realpestano>
> > > >
> > >
> > >
> > >
> > > --
> > > <http://www.advancedit.com.br/>Att,
> > >
> > > Rafael M. Pestano
> > >
> > > Desenvolvedor Java Cia. de Processamento de Dados do Rio Grande do Sul
> > > http://rpestano.wordpress.com/
> > > @realpestano <https://twitter.com/realpestano>
> > >
> >
>

Reply via email to