@Retention(value=RUNTIME) @Target(value=PARAMETER) public @interface Param
DataLoader annotation. DataLoader annotation is used to
provide test data to the test cases.
public void testWithStrongParameters(LibraryId id ,
@Param(name="itemid") ItemId
itemId) { .... }
Param.DataSupplier simply provides
the HashMap instance that was created while loading the data. This HashMap represents a single set of test
data for the test method.Param annotation, the framework will look for the
parameter with the specified name in the loaded test data.
@Test
@DataLoader(filePaths ={ "getItemsData.csv" })
public void testWithStrongParameters(LibraryId id
,@Param(name="itemid") ItemId itemId) { .... }
@Test @DataLoader(filePaths= {"getItemsData.csv" })
public void testGetItemsWithoutFileType( Map inputData) {
........
}
Converters. Converters are a mechanism for the user to translate
a map of key/value pair into custom objects that can be passed as input parameters to the test cases. For example, if
you want to pass a complex object as input parameter to a test case then you will simply write a custom converter
that extends AbstractConverter and will override the Converter.convert(Map) method. You can
look at example of CustomConverter here : https://github.
com/EaseTech/easytest-core/blob/master/src/test/java/org/easetech/easytest/example/ItemConverter.java
@Test
public void testArrayList(@Param(name="items") ArrayList<ItemId> items){
Assert.assertNotNull(items);
for(ItemId item : items){
System.out.println("testArrayList : "+item);
}
}
then all you have to do is : AbstractConverter in the BeforeClass method. Note that you should pass only the Concrete type as
parameter argument while extending the AbstractConverter and not the Abstract type or the interface type. You
can always override the default implementation of creating a specific type instance for use in your test cases by
overriding the AbstractConverter.instanceOfType() method.| Modifier and Type | Required Element and Description |
|---|---|
String |
name
The name of the parameter for which value needs to be fetched from the data set
|
| Modifier and Type | Optional Element and Description |
|---|---|
boolean |
convertEmptyToNull
Boolean identifying whether an empty value be converted to a null value or not
|
public abstract String name
public abstract boolean convertEmptyToNull
Copyright © 2014. All rights reserved.