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
Complex object as param #66
Comments
I answer to myself. XML should be like: <Entry key="myEntity" value="{ "name": "Administrador", "description": "", "state" : "true", "value" : "8" }" /> The " is correct, you need a double-quote to get JSON correctly parsed or you get an error. |
Hi Daniel, I am not sure whether it will work as I havent tested it myslef. But I have a feeling it will. Basically I have changed the double quotes in value to single quotes so that I can use double quotes for the JSON. Let me know if that worked. |
|
I'm back with this question... how would you define a object array with JSON? I have checked two methods, with no success: Attemp 1
with StackTrace:
Attemp 2
with StackTrace
Data is loaded, but instead of a collection for my type class I get a collection of LinkedHashMap, with all the entries as key/value pairs. Maybe this data input is not supported by EasyTest? |
Finally, I have overwritten my XMLDataLoader to parse JSON array of objects. I have had to do it in the DataLoader because Converter is not being executed given to a previous pre-parse, which results in a different type matching, and is not called. The semantics for JSON in my XML is:
As you see, I have added the implementation class to let Jackson JSON parser which is the type of objects in the list to fulfill. I leave my code solution here, if anyone else needs.
Exceptions have been muted because it is a conversion tryout, so if it fails it will be parsed using the default conversion. |
Again, sorry for replying late. Is it possible for you to contribute this change in code as a Pull Request to EasyTest Core object. I will then quickly incorporate it and will then plan a new release soon. Thanks, |
Hi Anuj, I will think in a cleaner way to implement in Core, just to be Jackson compatible (my solution is fast but is not compatible). I need to navigate deeper in EasyTest Core because I think is a collateral situation given for another functionallity. I will do it in next days. |
Hi again Anuj,
I have been testing with easytest on "basic" way, and now I'm trying to test passing a complex object as parameter.
For example:
@dataloader(filePaths = { "myXmlData.xml" })
testSave_withMyEntity(MyEntity myEntity){
myBo.save(myEntity);
}
And myXmlData.xml contains:
<TestMethod name="testSave_withMyEntity">
<TestRecord id="1">
<Description></Description>
<InputData>
<Entry key="name" value="Administrador" />
<Entry key="description" value="" />
<Entry key="state" value="true" />
<Entry key="value" value="8" />
</InputData>
</TestRecord>
</TestMethod>
When I test with JUnit, it shows the method with the given parameters in XML
testSave_withMyEntity{name=Administrador,description=,state=true,value=8}, but it does not make the instance of 'MyEntity', so test is failing.
What am I missing?
Thank you!
The text was updated successfully, but these errors were encountered: