Unit testing
Unit Testing in Visual Studio
Unit Testing in Visual Studio
  • What is testing?
    • Different types of tests
    • Benefits of unit testing
    • Characteristics of tests
    • Frameworks for testing
    • Unit testing and DevOps
  • ▶️Testing a console app
  • ▶️Testing a web app
  • 🧪Edabit Examples
Powered by GitBook
On this page
  • Testing a web app using XUnit
  • Screen shots
  • Repository for the above app
  • Clone the above repo
  • Requirements to run the app
  • Run the application

Testing a web app

PreviousTesting a console appNextEdabit Examples

Last updated 2 years ago

Testing a web app using XUnit

This is a simple asp.net core Razor Pages application to calculate the age of a person when he enters his date of birth in the home page. The result is shown in a second page after he click the submit.

The VSCode solution has 3 projects- one to hold the core logic (a class library), another to perform the testing of this core logic (XUnit project) and finally the last one is the actual web application for the end user.

Screen shots

Repository for the above app

Clone the above repo

git clone https://github.com/ravirammysore/KnowYourAge.git

Requirements to run the app

  1. VSCode IDE

Commands for installing the above requirements

dotnet --version
winget install dotnet-sdk-7
code --install-extension ms-dotnettools.csharp
code --install-extension formulahendry.dotnet-test-explorer

Run the application

  1. Close visual studio code and any command prompts if open

  2. Open a command to the inner folder where the app is cloned, example C:\Users\ravi_\Source\repos\Temp\KnowYourAge\KnowYourAge

  3. Issue the command code . (This should load the project in VSCode properly)

  4. Accept any suggestions by VS Code to restore assets, packages or extensions

  5. Use ctrl and F5 keys to run the application!

  6. Accept any prompts regarding security certificate from your browser

Ignore warning by browser

Your browser may warn about connection, click Advanced and then click the localhost.... link to start browsing the app!

You could also try installing the certificate manually as shown below:

Install the certificate

dotnet dev-certs https --trust

for VS Code

(for visual interface)

If you need to know how the project structure was created using VSCode and .net CLI, you can look into documentation.

▶️
.NET Core 7 SDK
C# Extension
.NET Core Test Explorer
GitHub - ravirammysore/KnowYourAge: Demo application used for learning DevOps!GitHub
Logo
this