From the course: Discovering .NET Aspire
Unlock this course with a free trial
Join today to access over 25,300 courses taught by industry experts.
Testing .NET Aspire apps - .NET Tutorial
From the course: Discovering .NET Aspire
Testing .NET Aspire apps
When we created our .NET Aspire app based on the Starter project template, we also opted for tests and indeed we got those tests. So let's have a look at them. And, essentially, it's pretty straightforward. We have a test project and we already checked that IsTestProject is set to true. And, well, the file is called WebTests, plural. But there's only one test in it at the moment, and that's the test that essentially creates an HTTP client, tries to access the web frontend, and then just checks whether the route page is properly returning HTTP 200 as the HTTP status code. So, essentially, whether everything works. And why don't we just add another test of our own here? I just copy and paste this. Forgive me for that anti-pattern. And then how about GetAPIReturnsOkStatusCode. And notice that when creating the HTTP client, we once again were using that "webfrontend" string, which was defined in the app host project here, webfrontend. So how about we also use the apiservice. So apiservice…