Contains tests for wasm project builds, eg. for aot, relinking, globalization etc. The intent is to check if the build inputs result in a correct app bundle being generated.
-
When running locally, it tests against a local workload install (based on
artifacts)- but this can be turned off with
/p:TestUsingWorkloads=false - in which case, it will run against a sdk that has updated workload
manifests for
wasm-tools*, but does not have the workload installed. Typically installed inartifacts/bin/dotnet-none.
- but this can be turned off with
-
On CI, both workload, and no-workload cases are tested
-
Running:
Linux/macOS: $ make -C src/mono/(browser|wasi) run-build-tests
Windows: .\dotnet.cmd build .\src\mono\wasm\Wasm.Build.Tests\Wasm.Build.Tests.csproj -c Release -t:Test -p:TargetOS=browser -p:TargetArchitecture=wasm
- Specific tests can be run via
XUnitClassName, andXUnitMethodName- e.g.
XUnitClassName=Wasm.Build.Tests.BlazorWasmTestsfor running class of tests - e.g.
XUnitMethodName=Wasm.Build.Tests.Blazor.MiscTests3.WithDllImportInMainAssemblyfor running a specific test.
- e.g.
The wasm.build.tests are built, and sent as a payload to helix, alongwith either sdk+no-workload-installed, or sdk+workload. And on helix the individual unit tests generate test projects, and build those.
Most of the tests are structured on the idea that for a given case (or combination of options), we want to:
- build once
- run the same build with different hosts, eg. Chrome, Firefox etc.
For this, the builds get cached using ProjectInfo as the key.
-
when running locally, the default is to test with workloads. For this, sdk with
$(SdkVersionForWorkloadTesting)is installed inartifacts/bin/dotnet-latest. And the workload packs are installed there using packages inartifacts/packages/$(Configuration)/Shipping.-
If the packages get updated, then the workload will get installed again.
-
Keep in mind, that if you have any non-test changes, and don't regenerate the nuget packages, then you will still be running tests against the "old" sdk
-
-
If you aren't explicitly testing workloads, then it can be useful to run the tests with
-p:TestUsingWorkloads=false, and this will cause the tests to use the build bits from the usual locations in artifacts, without requiring regenerating the nugets, and workload re-install. -
Each test is saved in directory with randomly generated name and unique
ProjectInfo.ProjectInfocan be used to find the binlogs, or cached builds.
SHOW_BUILD_OUTPUT- will show the build output to the consoleSKIP_PROJECT_CLEANUP- won't remove the temporary project directories generated for the tests
Blazor specific tests should be located in Blazor directory. If you are adding a new class with tests, list it in eng/testing/scenarios/BuildWasmAppsJobsList.txt. If you are adding a new test to existing class, make sure it does not prolong the execution time significantly. Tests run on parallel on CI and having one class running much longer than the average prolongs the total execution time.
If you want to test templating mechanism, use CreateWasmTemplateProject. Otherwise, use CopyTestAsset with either WasmBasicTestApp or BlazorBasicTestApp, adding your custom TestScenario or using a generic DotnetRun scenario in case of WASM app and adding a page with test in case of Blazor app. Bigger snippets of code should be saved in src/mono/wasm/testassets and placed in the application using methods: ReplaceFile or File.Move. Replacing existing small parts of code with custom lines is done with UpdateFile.