First of all, I haven't tried JUnit or any other testing framework so I hope you understand that I'm asking this kind of question.
I'm new to spock (and as I've already mentioned, I dont have any background any in testing frameworks) and I've created a simple app in grails. Now I want to create a code (unit test) to test the app that I made using spock (I hope you understand what I mean).
I've already read several articles about spock but I still don't have a good understanding of how to do it in my own app.
class DailyProfitController {
def update() {
params.date_month = (Integer.parseInt(params.date_month)<10)? "0" + params.date_month : params.date_month
params.date_day = (Integer.parseInt(params.date_day)<10)? "0" + params.date_day : params.date_day
params.date = params.date_year + "-" + params.date_month + "-" + params.date_day
def dailyProfit = new DailyProfit(params)
dailyProfit.save(flush:true, insert:false)
list()
}
def list(){
def dailyProfit = DailyProfit.list()
render view:"profitTable", model: [dailyProfit : dailyProfit]
}
}
Shown above is the controller and two methods, update and list. Assuming I want to create unit test code for this controller using spock, how will I do it?
Aucun commentaire:
Enregistrer un commentaire