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

TestFramework cannot be inherited #2993

Open
wuzxc1230123 opened this issue Aug 4, 2024 · 5 comments
Open

TestFramework cannot be inherited #2993

wuzxc1230123 opened this issue Aug 4, 2024 · 5 comments

Comments

@wuzxc1230123
Copy link

wuzxc1230123 commented Aug 4, 2024

My code version

<ItemGroup>
		<PackageReference Include="coverlet.collector" Version="6.0.0" />
		<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0" />
		<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
		<PackageReference Include="xunit" Version="2.5.3" />
		<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" />
	</ItemGroup>

I am rewriting XunitTestFramework in A Project,ProjectB references Project A, but fails to run HostTestStartup

[assembly: TestFramework("LJ.Test.Host.Web.HostTestStartup", "LJ.Test.Host.Web")]
namespace LJ.Test.Host.Web
{


    public  class HostTestStartup(IMessageSink messageSink) : XunitTestFramework(messageSink)
    {

     
        protected override ITestFrameworkExecutor CreateExecutor(AssemblyName assemblyName)
        {

            var hostRunOptions = WebHostOptions.Default;
           

            return new HostTestFrameworkExecutor(WebHost.Create(hostRunOptions), assemblyName, SourceInformationProvider, DiagnosticMessageSink);
        }

    }
}
@bradwilson
Copy link
Member

I'm not clear what you're asking for here.

@wuzxc1230123
Copy link
Author

[assembly: TestFramework("LJ.Test.Host.Web.HostTestStartup", "LJ.Test.Host.Web")]
no run HostTestStartup

@bradwilson
Copy link
Member

Please provide a repro project. Thanks!

@Urganot
Copy link

Urganot commented Sep 28, 2024

Hi,
I might have the same issue.
I have a test base class. there I have all my dependencies and common code.
Then I have other test projects that have the specific tests. those projects inherit from the base project.

The problem I came across is that eventhough I can run a test in the base project without any issues, the tests in the interiting projects are not run.
While trying to fix this I noticed that the tests are run correctly if I include the package "Microsoft.NET.Test.Sdk" in my test projects (not base project)

@bradwilson
Copy link
Member

Microsoft.NET.Test.Sdk is an absolute requirement to be able to use VSTest (dotnet test or Test Explorer, among other things).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants