• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
  • Grails中的Controller單元測試

    發表于:2010-01-29來源:作者:點擊數: 標簽:單元ControllerGrailscontroller
    Grails中的Controller單元測試 單元測試工具 對于Controller的單元測試,Grails也提供了很方便的支持,使得書寫非常簡單,有代碼為證: 單元測試代碼 1. class CategoryControllerTests extends Groovy TestCase { 2. 3. void setUp(){ 4. def test1= new Ca

      Grails中的Controller單元測試  單元測試工具

      對于Controller的單元測試,Grails也提供了很方便的支持,使得書寫非常簡單,有代碼為證:

      單元測試代碼

      1. class CategoryControllerTests extends GroovyTestCase {

      2.

      3. void setUp(){

      4. def test1= new Category(name: "Test1", parent: null).save()

      5. def test2= new Category(name: "Test2", parent: null).save()

      6. def test3= new Category(name: "Test3", parent: null).save()

      7.

      8. def test11= new Category(name: "Test11", parent: test1).save()

      9. def test12= new Category(name: "Test12", parent: test1).save()

      10. def test21= new Category(name: "Test21", parent: test2).save()

      11. }

      12.

      13. void testListRoot() {

      14. def controller= new CategoryController()

      15. //categoryList對應返回的model

      16. def categoryList= controller.list()?.categoryList

      17.

      18. assertEquals 3, categoryList.size()

      19. assertEquals 'Test1', categoryList[0].name

      20. assertEquals 'Test2', categoryList[1].name

      21. assertEquals 'Test3', categoryList[2].name

      22. }

      23.

      24. void testListTest1(){

      25. def controller= new CategoryController()

      26. //其中的params表示的是requestparameter,后面的id是傳入的參數。

      27. //對于session之類以此類推。

    原文轉自:http://www.kjueaiud.com

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>