feature spec / integration spec( request spec) / c

如题。最近写测试的时候开始有点晕,不知道feature spec / integration spec / controller spec都应该测试什么

比如说,有这样一个场景

已登陆的用户,可以新建帖子

那我的开发过程是这样的

新建一个feature spec文件,使用capybara来模拟上述内容

feature '已登录的用户,可以新建帖子' do  include_context '用户登录'  before { visit new_topic_path }  scenario '选择社区,填写标题和正文后,点击保存,可以新建一个帖子' do    expect {       select 'Testing', from: 'topic_node'      fill_in 'topic_title', with: '测试'      fill_in 'topic_content', with: '测试正文'      click_button '保存'    }.to change(Topic, :count).by(1)  endend

然后执行测试,根据失败提示来继续开发我原本是只写feature的测试来保证覆盖率的,有高手说,feature只测试功能,应该用`unit spec’来保证测试覆盖率OK。那我把原来写在feature里面的各种验证的测试都改成unit spec,也就是controller spec, model specfeature spec里面只保留基本的正常流程的spec。到这里为止我还都理解。但之后就有点糊涂了。如果这样的话,那request spec 里面应该写哪些测试呢?

feature spec / integration spec( request spec) / c

相关文章:

你感兴趣的文章:

标签云: