zoukankan      html  css  js  c++  java
  • spring测试

    今天在用spring做集成测试的时候,代码如下

     @Test
        @DatabaseSetup({"userData.xml", "emptyUserMailTemplateData.xml","systemMailTemplateData.xml"})
        @ExpectedDatabase(value = "saveUserMailTemplateExpected.xml", assertionMode = DatabaseAssertionMode.NON_STRICT)
        public void createNewTemplateShouldAddTemplateAndRedirectSuccessView() throws Exception {
            mockMvc.perform(post("/user/template/add").with(user(securityUser()))
                    .param("name", "aaa")
                    .param("approveStatus", "4")
                    .param("template.subject", "test template")
                    .param("template.body", "test template")
                    .param("systemTemplateId",new String[]{"1"})
                    .sessionAttr("template", new UserMailTemplate()))
                    .andExpect(status().isFound())
                    .andExpect(view().name("redirect:/user/template/create_or_update_success"));
        }

    测试一直失败,可是仅看controller层和这里的测试方法是没有问题的,但是一直测试不成功,显示 expect1 actual 4,原来是

     @ExpectedDatabase

    这个注释的原因,因为

    saveUserMailTemplateExpected.xml里面的数据该字段为1,而我存的时候是设为4,好吧,忘了留意 那个注解了!其实这一整套测试还是很严谨的
    
    
  • 相关阅读:
    图片音乐 上传、下载
    表格类型数据,Excel csv导入,导出操作
    逐行读取txt文件,分割,写入txt。。。上传,下载
    性能分析四
    性能分析三
    postman断言
    postman+Newman语法参数
    shell_03
    shell_02
    shell_01
  • 原文地址:https://www.cnblogs.com/minjay/p/6649887.html
Copyright © 2011-2022 走看看