Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Added the docs for GettingStartedWithTests #16314

Merged
merged 8 commits into from Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 59 additions & 0 deletions doc/articles/getting-started/GettingStartedWithTests.md
vatsashah45 marked this conversation as resolved.
Show resolved Hide resolved
@@ -0,0 +1,59 @@
---
vatsashah45 marked this conversation as resolved.
Show resolved Hide resolved
uid: Uno.Authoring.Tests
---
# How-To: Creating an application with tests using Uno.Extensions
vatsashah45 marked this conversation as resolved.
Show resolved Hide resolved

This tutorial will walk through how to create an Uno application with tests.

> [!NOTE]
> Make sure to setup your environment first by [following our instructions](xref:Uno.GetStarted.vs2022).

## 1. Exploring the Solution

The generated solution will contain:

* *MyProjectName* - for application logic, and other constructs like view models and services, as well as the pages, controls, and other views that make up the UI of the application.
* *MyProjectName.Tests* and *MyProjectName.UI.Tests* - for writing unit and UI tests respectively.

![The structure of the generated solution](Assets/ProjectStructure-Tests-min.png)

## 2. Running the Application

* Select a target from the drop-down as pictured below

![A screenshot of the generated targets](Assets/GeneratedTargets-min.png)

* Click the "play" button, or press F5 to start debugging. The project will be compiled and deployed based on the target platform. For more detailed instructions specific to each platform, refer to the [Debug the App](xref:Uno.GettingStarted.CreateAnApp.VS2022#debug-the-app) documentation.

## 3. Running the Unit Tests

* Right click the project inside Tests\\MyProjectName.Tests to open the context menu

* Select *Run Tests*

The application will be compiled and the test cases will run.

> [!TIP]
> If the 'Run Tests' menu item doesn't exist, you need to Rebuild the solution to get Visual Studio to detect the available tests.

## 4. Running the UI tests

* As demonstrated on step 3, select the **WebAssembly** target from the drop-down.

* Press Ctrl + F5 to start the WASM project without debugging.

* Once the application is compiled, it will launch inside your default browser. Take note of the URL which should look something like this: https://localhost:5000/Main

* Find the project *Tests\\MyProjectName.UI.Tests* and locate the *Constants.cs* file.

* Open *Constants.cs* and update the WebAssemblyDefaultUri constant.

It should appear similar to this:

```cs
public readonly static string WebAssemblyDefaultUri = "https://localhost:5000/";
```

* Go back to the project *Tests\\MyProjectName.UI.Tests* and right click. Then, *Run Tests*.

![Test Explorer in VS](Assets/TestExplorer-min.png)
2 changes: 2 additions & 0 deletions doc/articles/toc.yml
Expand Up @@ -155,6 +155,8 @@
items:
- name: Using the Uno.SDK
href: xref:Uno.Features.Uno.Sdk
- name: Getting Started With Tests
href: xref:Uno.Authoring.Tests
- name: Platform-specific C# code
href: platform-specific-csharp.md
- name: Platform-specific XAML markup
Expand Down