I'm working on a project where the domain is defined in french. I'm using JGiven to write tests and I'm trying to get the report completely in french. I'm using the Spring Test infrastructure by inheriting SpringScenarioTest
in my test classes.
Here's an example of what I did:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = SpringConfig.class)
public class TrainDateTest extends SpringScenarioTest<GivenTrainDate, WhenTrainDate, ThenTrainDate> {
@Test
@As("Création d'un train date")
public void creation_d_un_train_date() {
given().un_train_date();
when().je_lance_la_creation_du_train_date();
then().le_train_date_resultant_doit_avoir_un_id_en_base();
}
}
I found out how to translate intro word like and()
or with()
using the @IntroWord
annotation in my Stage
classes, but how can I translate the given()
, when()
and then()
intro words?
The problem seems to be that these intro words are defined by the Scenario
class which is created by the ScenarioTestBase
class and I can't find a way to override this behavior without rewriting the entire class hierarchy.
Is there any way to do this ?
Thank you
Yes you can. You can have a look at the com.tngtech.jgiven.lang.de.SzenarioTestBasis
which provides this for German already. Just create a subclass of SpringScenarioTest
and define the methods that you need as follows:
public class FrenchSpringScenarioTest<ETANTDONNE, QUAND, ALORS> extends
SpringScenarioTest<ETANTDONNE, QUAND, ALORS> {
public ETANTDONNE etant_donne() {
return getScenario().given( "etant donné" );
}
public QUAND quand() {
return getScenario().when( "quand" );
}
public ALORS alors() {
return getScenario().then( "alors" );
}
}