Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI,

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.
Posted
Updated 7-Sep-17 21:12pm

1 solution

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]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900