在ASP.NET核心和角度js应用程序中运行单元测试用例。 [英] Running unit test cases in ASP.NET core and angular js application.

查看:124
本文介绍了在ASP.NET核心和角度js应用程序中运行单元测试用例。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI,



如何从asp.net核心和角度应用程序运行单元测试用例。



这里我的项目有两个解决方案asp.net解决方案和角度解决方案。 asp.net解决方案用于创建Web API,角度解决方案用于调用Web API并执行CRUD操作。

这里的问题是如果我想运行角度解决方案我需要保持asp.net核心解决方案处于运行模式。然后只有api将处于启用模式并且我们可以访问数据。



这里我在asp.net核心解决方案本身进行单元测试如果我保留该解决方案运行模式运行测试选项将不可见。如果我从运行模式停止应用程序它将启用所以我没有得到任何与数据库的联系。



如何进行单元测试。

例如我想通过单元测试用例将一些记录插入数据库。 br />


请帮我解决这个问题。



提前致谢。



我尝试了什么:



我尝试在IIS中托管整个应用程序以便应用程序永远可见。这也是行不通的。



how to run unit test cases from asp.net core and angular application.

here my project have two solutions asp.net solution and angular solution. asp.net solution is for creating web API's and angular solution is for calling that web API's and doing the CRUD operations.
here problem is if i wants to run angular solution i need to keep a asp.net core solution is in running mode. then only that api's will be in enable mode and we can access data.

here i am doing unit testing in asp.net core solution itself if i keep that solution in running mode "run tests" option will not be visible. if i stop the application from running mode it will be enable so i am not getting any contact with database .

how can i do the unit testing.,
for example i wants to insert some record into database through that unit test case .

Please help me out of this issue.

Thanks in advance.

What I have tried:

I tried with hosting an entire application in IIS so that the application is always visible. that is also not working.

推荐答案

我们的开发环境处于相同的情况。我们正在开发一个包含带有Angular前端的web api(微服务)的解决方案。为了测试,我们使用SpecFlow和nUnit对API进行单元测试。我们通过实际启动API并在API之间来回发布模型(DTO)来测试我们测试的场景,如果结果符合预期则测试。



顶部我们使用完全相同的SpecFlow场景来启动前端的selenium测试。我们不会在这些测试中包含所有测试,但最重要的方案也将包含在这些测试中。通过这种方式,我们确保前端仍然能够在团队交付的每个版本中为最终用户执行最重要的任务。开发/维护前端测试非常昂贵,这也是我们在前端测试中不包括所有单元测试场景的原因。




这接近我们现在用于API测试的解决方案:

使用OWIN和Specflow进行Web API 2的端到端测试Mohammad Ruhul Amin [ ^ ]

[/ edit]
Our development environment is in the same situation. We're developing a solution containing web api's (micro services) which have an Angular front-end. For testing, we unit test the API's using SpecFlow and nUnit. We write scenarios which we test by actually starting the API's and posting models (DTO's) back and forth between the API's and test if the outcome is as expected.

On top of the, we use the exact same SpecFlow scenarios to start selenium tests for the front-end. We don't include all tests in these test, but the most important scenarios will be included in these tests as well. This way we make sure that out front-end is still capable of performing the most important tasks for the end-user in each and every version delivered by the team. Front-end tests are pretty expensive to develop / maintain, which is why we don't include all unit test scenarios in the front-end tests as well.

[edit]
This comes close to the solution we use right now for API testing :
End to End Testing of Web API 2 using OWIN and Specflow | Mohammad Ruhul Amin[^]
[/edit]


这篇关于在ASP.NET核心和角度js应用程序中运行单元测试用例。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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