Last active
December 17, 2015 11:09
-
-
Save MarvinSchramm/5599571 to your computer and use it in GitHub Desktop.
Problem with cucumber-weld, every step creates a new Objekt of the stepclass. which means it is not possible to create a state over several methods.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Feature: GenericDAO | |
Abstract Object which offers the basic capability of CRUD to all specific DAO'S | |
Scenario: Create GenericEntity via JPA | |
Given there is a valid generic entity | |
When I persist the valid generic entity | |
Then lastModificationTimestamp in the entity should be set | |
And creationTimestamp in the entity should be set | |
And persist should only be called once |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private EntityManager em; | |
private DataAccessObject dataAccessObject; | |
private GenericEntity genericEntity; | |
public GenericDataAccessObjectStepDefs(){ | |
System.out.println("i get called for every step"); | |
} | |
@Before | |
public void before() | |
em = mock(EntityManager.class); | |
dataAccessObject = spy(new DataAccessObjectJPA(GenericEntity.class, em) { | |
}); | |
} | |
@Given("^there is a valid generic entity$") | |
public void there_is_a_valid_generic_entity() { | |
genericEntity = spy(new GenericEntity() { | |
}); | |
} | |
@When("^I persist the valid generic entity$") | |
public void I_call_the_generic_create_method() throws SystemException { | |
dataAccessObject.create(genericEntity); | |
} | |
@Then("^lastModificationTimestamp in the entity should be set$") | |
public void lastModificationTimestamp_in_the_entity_should_be_set(){ | |
verify(genericEntity,atMost(1)).setLastModificationTimestamp(anyLong()); | |
} | |
@And("^creationTimestamp in the entity should be set$") | |
public void creationTimestamp_in_the_entity_should_be_set(){ | |
verify(genericEntity,atMost(1)).setCreationTimestamp(anyLong()); | |
} | |
@And("^persist should only be called once$") | |
public void persist_should_only_be_called_once(){ | |
verify(em,atMost(1)).persist(genericEntity); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependency> | |
<groupId>info.cukes</groupId> | |
<artifactId>cucumber-core</artifactId> | |
<version>1.1.2</version> | |
<scope>test</scope> | |
</dependency> | |
<dependency> | |
<groupId>info.cukes</groupId> | |
<artifactId>cucumber-java</artifactId> | |
<version>1.1.2</version> | |
<scope>test</scope> | |
</dependency> | |
<dependency> | |
<groupId>info.cukes</groupId> | |
<artifactId>cucumber-weld</artifactId> | |
<version>1.1.2</version> | |
<scope>test</scope> | |
</dependency> | |
<dependency> | |
<groupId>info.cukes</groupId> | |
<artifactId>cucumber-junit</artifactId> | |
<version>1.1.2</version> | |
<scope>test</scope> | |
</dependency> | |
<dependency> | |
<groupId>org.jboss.weld.se</groupId> | |
<artifactId>weld-se</artifactId> | |
<version>2.0.0.Final</version> | |
<scope>test</scope> | |
</dependency> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RunWith(Cucumber.class) | |
@Cucumber.Options(format = {"pretty", "html:target/cucumber-html-report", "json-pretty:target/cucumber-json-report.json"}) | |
public class RunCukesTest { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment