-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## [1.4.2] - 2023-12-05 - Issue where playmode tests were not recording test results correctly after the first run was fixed. (DSTR-984) - A timeout message is now printed when the test failures occurs before the test finishes. (DSTR-476) - Nested enumerators are now having their first step executed in the same frame as the parent enumerator. (DSTR-888) - Fixed an issue where test projects without PlayMode tests would give the error "No callbacks received." when running in batchmode on some Unity versions.
- Loading branch information
Unity Technologies
committed
Dec 5, 2023
1 parent
d7833c1
commit dfe4a2e
Showing
38 changed files
with
209 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# What's new in version 1.4 | ||
|
||
This page summarizes new features, improvements, and issues resolved in version 1.4 of Unity Test Framework. | ||
|
||
## Added | ||
### API updates | ||
|
||
In this version, we introduced several API changes: | ||
* Added API for saving results | ||
* Added API for canceling test runs | ||
* Added overloads of LogAssert.Expect which allow users to expect a log message without specifying a severity, which will match logged messages of any severity. | ||
|
||
### Ignore tests based on arguments | ||
|
||
This version introduces the ParameterizedIgnoreAttribute which allows ignoring tests based on arguments which were passed to the test method of a [parameterized test](./reference-tests-parameterized.md). | ||
|
||
## Updated | ||
### Revised Test Runner UI | ||
This version includes a revised Test Runner window and several usability improvements: | ||
* Added a third tab to the Test Runner window, for running in a player explicitly. This makes it easier to run a subset of tests, as well as retaining the test results from the latest player run. | ||
* Moved the run and action buttons to the bottom of the window, to separate them from the filters. | ||
* The stack traces are clickable, and will open the relevant file in the external editor. | ||
* When searching, the parents of the matching tests are expanded, to make it easier to see the context of the matching tests. | ||
|
||
] | ||
|
||
## Fixed | ||
This version includes many bug fixes and performance improvements. For a full list of changes and updates in this version, see the Unity Test Framework package [changelog](https://docs.unity3d.com/Packages/[email protected]/changelog/CHANGELOG.html). |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,32 @@ | ||
# Workflow: **How to create a new test assembly** | ||
# Workflow: Creating test assemblies | ||
|
||
Unity Test Framework looks for a test inside any assembly that references [NUnit](http://www.nunit.org/). We refer to such assemblies as **Test Assemblies**. **Play Mode** and **Edit Mode** tests need to be in separate assemblies. | ||
UTF looks for tests in a **Test Assembly**, which is any assembly that references Nunit. | ||
|
||
The [Test Runner](./getting-started.md) UI helps you set up **TestAssemblies**: | ||
The Test Runner UI helps you set up test assemblies: | ||
|
||
1. Select the **Assets** folder in your Project window. | ||
2. Open the **Test Runner** window (menu: **Window** > **General** > **Test Runner**). | ||
3. In the **Test Runner** window, the **EditMode** tab should be selected by default. Click **Create EditMode Test Assembly Folder**. | ||
1. Select the Assets folder in your Project window. | ||
2. Open the Test Runner window (menu: **Window** > **General** > **Test Runner**). | ||
3. In the **Test Runner** window, select **Create a new Test Assembly Folder in the active path**. | ||
|
||
 | ||
 | ||
|
||
This creates a *Tests* folder in your project Assets with a corresponding `.asmdef` file with the required references. You can change the name of the new [Assembly Definition](https://docs.unity3d.com/Manual/ScriptCompilationAssemblyDefinitionFiles.html) and press Enter to accept it. | ||
Alternatively, you can go via the **Assets** menu: | ||
|
||
 | ||
1. Select the Assets folder in your Project window. | ||
2. Create a new Test Assembly Folder (menu: **Assets** > **Create** > **Testing** > **Test Assembly Folder**). | ||
|
||
Click on the assembly definition file to inspect it in the Inspector window. You'll see that it has references to **nunit.framework.dll** under Assembly References, and to **UnityEngine.TestRunner** and **UnityEditor.TestRunner** under Assembly Definition References. This tells Unity Test Framework that this is a test assembly. | ||
This creates a *Tests* folder in your project Assets with a corresponding `.asmdef` file with the required references. You can change the name of the new [Assembly Definition](https://docs.unity3d.com/Manual/ScriptCompilationAssemblyDefinitionFiles.html) and press Enter to accept it. | ||
|
||
The checkbox selections under **Platforms** determine which platforms the test assembly can run on. Assemblies created through the **Test Runner** target the **Editor** only by default. **Any Platform** or a specific platform other than **Editor** makes the tests you add run in Play Mode by default. | ||
 | ||
|
||
> **Note**: The **UnityEditor.TestRunner** reference is only available for [Edit Mode tests](./edit-mode-vs-play-mode-tests.md#edit-mode-tests). | ||
Click on the assembly definition file to inspect it in the **Inspector** window. You'll see that it has references to **nunit.framework.dll***,* **UnityEngine.TestRunner,** and **UnityEditor.TestRunner** assemblies. This tells UTF that this is a test assembly. | ||
|
||
 | ||
The checkbox selections under **Platforms** determine which platforms the test assembly can run on. Assemblies created through the **Test Runner** target the **Editor** only by default. **Any Platform** or a specific platform other than **Editor** makes it possible to run any Play Mode tests in the assembly on standalone Players for the additional platforms. | ||
|
||
## Reference other assemblies in your Test Assemblies | ||
|
||
To reference other assemblies from your Test Assemblies: | ||
 | ||
|
||
1. Create your Test Assembly as described above. | ||
2. Create an Assembly Definition for the scripts you want to reference, refer to [Create an Assembly Definition asset](https://docs.unity3d.com/Manual/ScriptCompilationAssemblyDefinitionFiles.html#create-asmdef). | ||
3. Add a reference to the Assembly Definition created in Step 2 to your Test Assembly, refer to [Referencing another assembly](https://docs.unity3d.com/Manual/ScriptCompilationAssemblyDefinitionFiles.html#reference-another-assembly). | ||
> **Note**: The **UnityEditor.TestRunner** reference is only available for [Edit Mode tests](./edit-mode-vs-play-mode-tests.md#edit-mode-tests). | ||
## Additional resources | ||
You can repeat the steps above as many times as you like to create additional Test Assemblies. The first Test Assembly folder you create is named *Tests* by default and subsequent ones are named *Tests 1*, *Tests 2*, and so on. Remember that you can always rename the assemblies but each assembly name must be unique. | ||
|
||
Refer to the Unity Manual page on [Assembly definitions](https://docs.unity3d.com/Manual/ScriptCompilationAssemblyDefinitionFiles.html) for more detail on using Assembly Definition files to manage references. | ||
> **Note**: Changing the file name of the assembly definition file does not affect the value of the **Name** property in the file. Use the **Inspector** window or edit the .asmdef direclty in a text editor to make sure the name property is properly changed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,31 @@ | ||
# Workflow: How to create a test | ||
# Workflow: Creating tests | ||
|
||
To create a test, do the following: | ||
To create a test through the **Test Runner** window: | ||
|
||
1. Create your *Test* [assembly folder](./workflow-create-test-assembly.md) and select it in the **Project** window. | ||
2. Click the button **Create Test Script in current folder** option in the **Test Runner** window. | ||
 | ||
3. It creates a *NewTestScript.cs* file in the *Tests* folder. Change the name of the script, if necessary, and press Enter to accept it. | ||
1. [Create your Test Assembly folder](./workflow-create-test-assembly.md) and select it in the **Project** window. | ||
2. Open the Test Runner window (menu: **Window** > **General** > **Test Runner**). | ||
3. Click the **Create a new Test Script in the active path** button in the **Test Runner** window. | ||
|
||
 | ||
|
||
Now you’ll see two sample tests in the Test Runner window: | ||
|
||
 | ||
|
||
Now you can open the tests in your favorite script editor. | ||
|
||
You can also create test scripts by navigating to **Assets** > **Create > Testing** > **C# Test Script**, unless adding a test script would result in a compilation error. | ||
|
||
> **Note**: Unity does not include `TestAssemblies` ([NUnit](http://www.nunit.org/), Unity Test Framework, and user script assemblies) when using the normal build pipeline, but does include them when using **Run on <Platform>** in the Test Runner window. | ||
Alternatively, use the **Asset** menu: | ||
|
||
## Create additional tests | ||
1. In the **Project** window, select the new folder. | ||
2. Create a new test script in the folder (menu: **Assets > Create > Testing > C# Test Script**). | ||
|
||
To create another set of tests: | ||
This creates a `NewTestScript.cs` file in the *Tests* folder with some sample tests to get you started. Change the name of the script, if necessary, and press Enter to accept it. | ||
|
||
1. In the **Project** window, select **Assets**. | ||
2. Create a new test assembly folder (menu: **Assets > Create> Testing > Tests Assembly Folder**). | ||
3. In the **Project** window, select the new folder. | ||
4. Create a new test script in the folder (menu: **Assets > Create > Testing > C# Test Script**). | ||
|
||
The assembly definition is assigned the same name as your new asset. To rename it, change the **Name** in the **Inspector** window. Assembly definition names must be unique. | ||
|
||
> **Note**: Changing the file name of the assembly definition file does not affect the value of the **Name** property in the file. Use the **Inspector** window to make sure the name is properly changed. | ||
By default **Any Platform** is preselected as the target platform for the new assembly, which means the test script appears as a PlayMode test in the TestRunner window. To change it to an EditMode test, in the **Inspector** window select **Editor** only under **Platforms**. | ||
|
||
New assemblies created through the **Assets** menu should automatically include references to `UnityEngine.TestRunner` and `UnityEditor.TestRunner`. If these references are missing, add them in the **Inspector** window under **Assembly Definition References**: | ||
 | ||
|
||
 | ||
Now you’ll see the sample tests in the Test Runner window: | ||
|
||
## Filters | ||
 | ||
|
||
If you have a lot of tests, and you only want to view/run a sub-set of them, you can filter them in three ways (see image above): | ||
Now you can open the tests in your favorite script editor. | ||
|
||
* Type in the search box in the top left | ||
> **Note**: Unity does not include test assemblies (NUnit, Unity Test Framework, and user script assemblies) when using the normal build pipeline, but does include them when using **Run on <Platform>** in the **Test Runner** window. | ||
* Click a test class or fixture (such as **NewTestScript** in the image above) | ||
## Creating Play Mode tests | ||
|
||
* Click one of the test result icon buttons in the top right | ||
The process for creating a Play Mode test is the same as for creating an Edit Mode test. The only relevant differences are: | ||
|
||
* Play Mode tests that need to [run in a standalone platform Player](./workflow-run-playmode-test-standalone.md) should be in an assembly that references the required platform. | ||
|
||
For more information, see [Edit Mode vs. Play Mode tests](./edit-mode-vs-play-mode-tests.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.