You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 4610cb7
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/site/docs/misc-test-tips.md
+58Lines changed: 58 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -102,3 +102,61 @@ With xUnit, this can be done as follows:
102
102
## Easier HTML copying/pasting
103
103
104
104
When writing tests in `.cs` files, you may want to copy/paste HTML into C# strings from something like a Razorfile, forexample. Thisistedioustodomanuallyasyouhavetoescapequotesandotherspecialcharacters, forexample `<divclass="alert">` needstobewrittenas `"<div class=\"alert\">"`. Theextension [SmartPaster](https://marketplace.visualstudio.com/items?itemName=martinw.SmartPaster) automatically escapes any characters that need to be escaped when it is used to copy strings.
105
+
106
+
## Testing components that use native dependencies
107
+
108
+
BlazorWebAssemblyappscancall [nativecodecompiledtoWebAssembly](https://learn.microsoft.com/en-us/aspnet/core/blazor/webassembly-native-dependencies) through `[DllImport]`. bUnit does not run tests in WebAssembly. Tests run on the regular .NET runtime of the machine running them, the same way a Blazor Server app does. A native library that is only built for WebAssembly, for example C files added with `<NativeFileReference>`, is therefore not available in a test, and calling it throws a `DllNotFoundException`.
-**Shipanativebinaryfortheoperatingsystemthetestsrunon.**IfthelibraryorNuGetpackageincludesnativebinariesforWindows, LinuxormacOS, forexampleinthe [architecture-specificfolders](https://learn.microsoft.com/en-us/nuget/create-packages/supporting-multiple-target-frameworks#architecture-specific-folders) of a NuGet package, the `[DllImport]` calls work in bUnit like in any other .NET app. Make sure there is a binary for every OS your tests run on, including CI.
0 commit comments