To test Unit Test we need 2 steps:
- Create new Object in setUp function.
- Create some function tests.
Step 1:
In this example, I create class from abstract class. With class Feed is abstract class.
void setUp() {
feed = [jsonForRelatedEntity: { ->
[
id: 1,
title: "Feed Title",
date: new Date('2010/10/11')
]
}] as Feed
}
Step 2:
Create some function test.
/**
* Test function json
* @author tien.nguyen
*/
void testJSON() {
def json = feed.json()
assertEquals "Feed Title", json.title
assertEquals new Date('2010/10/11'), json.date
println json
}
Good luck to you.
No comments:
Post a Comment