单元测试控制器动作 [英] Unit testing a controller action

查看:123
本文介绍了单元测试控制器动作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的一次单元测试讲座中,我的教授说测试控制器动作是在功能测试下进行的,测试控制器的最佳实践是对我们在其中使用的各种独立功能进行单元测试,如服务层功能。

我们假设写一篇关于上述证据并说明示例的论文。

控制器动作是否属于功能测试,如果确实如此那么为什么建议测试控制器动作结果呢?

有人可以帮我吗?

解决方案

我想说的是我的个人意见那。许多专家可能会同意/不同意。所以需要有意见2.

控制器动作测试不是功能测试。它是UI测试的一部分。哪些将是非功能性测试的功能的一部分取决于原始方法/行为的部分。我们知道Controller动作方法的职责是它接收用户输入并为数据/逻辑调用适当的模型并呈现其负责任的视图。所以我认为主要责任是委托给适当的观点(ActionResult)。从这个意义上讲,我认为它不是功能测试的一部分。


during one of my lectures in unit testing, my professor stated that testing a controller action comes under functional testing, and that the best practice to test the controller is to unit test the various independent functions that we are using in it like the service layer functions.
we are suppose to write a paper on the above justifying it and stating examples.
Is it true that controller actions come under functional testing, if it does then why is it recommended to test controller action result?
Can anyone help me here?

解决方案

I want to say my personal opinion on that. Many experts may agree/disagree. So need there opinion 2.
Controller Action test is not functional testing. It is part of UI testing. Which will be part of functional which will be non functional testing depends on the parpose of original method/behaviour. We know that Controller action method''s responsibility is it receive user input and call appropriate model for data/logic and render its responsible view. So i think main responsibility is delegate to appropriate view(ActionResult). In that sense i think it is not part of functional testing.


这篇关于单元测试控制器动作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆