Reqnroll BDD tests not working with a Blazor Maui Hybrid app

I created a new Maui Blazor app with VS 2022. I have the Reqnroll plugin installed and created a new project within the solution. I added a project reference to the first Maui Blazor app just like the documentation states. (Reqnroll documentation)

I changed the TargetFrameworks in both projectfiles to “net8.0-windows10.0.19041.0”. I build both projects after making a dummy test which works as expected. (Both application also run without any issues) But when I run “dotnet test” in the terminal I get the following error:

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
Given The class has been instantiated
-> error: The type initializer for '<Module>' threw an exception. (0,1s)
When The function is called
-> skipped because of previous errors
Then it should return true
-> skipped because of previous errors

  Failed CallingTestFunction [231 ms]
  Error Message:
   System.TypeInitializationException : The type initializer for '<Module>' threw an exception.
  ----> System.TypeInitializationException : The type initializer for 'WinRT.ActivationFactory`1' threw an exception.
  ----> System.Runtime.InteropServices.COMException : Class not registered (0x80040154 (REGDB_E_CLASSNOTREG))
  Stack Trace:
   ...

Here are my project files:

Maui Blazor

<Project Sdk="Microsoft.NET.Sdk.Razor">

    <PropertyGroup>
        <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041.0</TargetFrameworks>

        <OutputType>Exe</OutputType>
        <RootNamespace>TestForReqnroll</RootNamespace>
        <UseMaui>true</UseMaui>
        <SingleProject>true</SingleProject>
        <ImplicitUsings>enable</ImplicitUsings>
        <EnableDefaultCssItems>false</EnableDefaultCssItems>
        <Nullable>enable</Nullable>

        <!-- Display name -->
        <ApplicationTitle>TestForReqnroll</ApplicationTitle>

        <!-- App Identifier -->
        <ApplicationId>com.companyname.testforreqnroll</ApplicationId>

        <!-- Versions -->
        <ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
        <ApplicationVersion>1</ApplicationVersion>

        <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
        <TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
        <Platforms>x64</Platforms>
    </PropertyGroup>

    <ItemGroup>
        <!-- App Icon -->
        <MauiIcon Update="ResourcesAppIconappicon.svg" ForegroundFile="ResourcesAppIconappiconfg.svg" Color="#512BD4" />

        <!-- Splash Screen -->
        <MauiSplashScreen Include="ResourcesSplashsplash.svg" Color="#512BD4" BaseSize="128,128" />

        <!-- Images -->
        <MauiImage Include="ResourcesImages*" />
        <MauiImage Update="ResourcesImagesdotnet_bot.svg" BaseSize="168,208" />

        <!-- Custom Fonts -->
        <MauiFont Include="ResourcesFonts*" />

        <!-- Raw Assets (also remove the "ResourcesRaw" prefix) -->
        <MauiAsset Include="ResourcesRaw**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
    </ItemGroup>

    <ItemGroup>
        <PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
        <PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" />
        <PackageReference Include="Microsoft.AspNetCore.Components.WebView.Maui" Version="$(MauiVersion)" />
        <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
    </ItemGroup>

</Project>

The test project

<Project Sdk="Microsoft.NET.Sdk.Razor">
    <PropertyGroup>
      <TargetFrameworks>net8.0-windows10.0.19041.0</TargetFrameworks>
      <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <Platforms>x64</Platforms>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
    <PackageReference Include="Reqnroll.NUnit" Version="1.0.0" />
    <PackageReference Include="nunit" Version="3.14.0" />
    <PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
    <PackageReference Include="FluentAssertions" Version="6.12.0" />
  </ItemGroup>

  <ItemGroup>
    <Folder Include="Drivers" />
    <Folder Include="Support" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..TestForReqnrollTestForReqnroll.csproj" />
  </ItemGroup>

</Project>

Test step definition

using NUnit.Framework;
using TestForReqnroll.Components;

namespace TestForReqnroll.test.StepDefinitions
{
    [Binding]
    public class TestStepDefinitions
    {
        private testClass testClass;

        [Given("The class has been instantiated")]
        public void GivenTheClassHasBeenInstantiated()
        {
            testClass = new testClass();
        }

        [When("The function is called")]
        public void WhenTheFunctionIsCalled()
        {
            testClass.testFunction();
        }

        [Then("it should return true")]
        public void ThenItShouldReturnTrue()
        {
            Assert.AreEqual(true, true);
        }
    }
}

and a screenshot of my entire solution

New contributor

ninjagast is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật