Open Blueknight10001 opened 5 years ago
HI @Blueknight10001
This ticket is a bit stale (all my fault), did you get this working? Otherwise seeing your project file would help to further diagnose.
I've also been able to reproduce this issue using the example in the readme.
My test cluster is created like so:
using Elastic.Elasticsearch.Xunit;
[assembly: Xunit.TestFrameworkAttribute("Elastic.Elasticsearch.Xunit.Sdk.ElasticTestFramework", "Elastic.Elasticsearch.Xunit")]
namespace Elastic.Test {
public class TestCluster : XunitClusterBase {
public TestCluster() : base(new XunitClusterConfiguration("7.8.0")) { }
}
}
And used in the test:
using Elastic.Elasticsearch.Xunit;
using Elastic.Elasticsearch.Xunit.XunitPlumbing;
using Elasticsearch.Net;
using FluentAssertions;
using Nest;
namespace Elastic.Test {
public class ExampleTest {
public ExampleTest(TestCluster cluster) {
this.Client = cluster.GetOrAddClient(c => {
var nodes = cluster.NodesUris();
var connectionPool = new StaticConnectionPool(nodes);
var settings = new ConnectionSettings(connectionPool).EnableDebugMode();
return new ElasticClient(settings);
});
}
private ElasticClient Client { get; }
[I]
public void SomeTest() {
var rootNodeInfo = this.Client.RootNodeInfo();
rootNodeInfo.Name.Should().NotBeNullOrEmpty();
}
}
}
My project file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Elastic.Elasticsearch.Xunit" Version="0.2.4" />
<PackageReference Include="NEST" Version="7.8.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
<PackageReference Include="FluentAssertions" Version="5.1.2" />
</ItemGroup>
</Project>
I've also tried updating the versions of NEST
and Xunit
but that doesn't seem to change anything. I'm running the tests through the Test Explorer
in Visual Studio Professional 2019 (16.6.2)
any news on this? I am experiencing exactly the same issue. @jpdunn , @Blueknight10001 have you been able to somehow resolve the problem?
for me I was able to resolve it by downgrading xunit references to:
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
Also curious about the progress of this issue? Using xunit 2.4.x doesn't seem to find any tests but using 2.3.1 as stated above works fine?
I can confirm this is a problem with xUnit 2.4.X (Visual Studio 2019) that seems to work fine with 2.3.1.
Hi, I found solution :)
[assembly: Xunit.TestFrameworkAttribute("Elastic.Elasticsearch.Xunit.Sdk.ElasticTestFramework", "Elastic.Elasticsearch.Xunit")]
public ExampleTest(TestCluster cluster)
Should be:
public ExampleTest()
new
var cluster = new TestCluster();
Fact
attribute instead of I
.
[I]
public void SomeTest() {
Should be:
[Fact]
public void SomeTest() {
All my tests are green. The versions of the packages that I use today are the newest.
net6.0
"Elastic.Elasticsearch.Xunit" Version="0.3.1"
"Microsoft.NET.Test.Sdk" Version="17.2.0"
"xunit" Version="2.4.1"
"xunit.runner.visualstudio" Version="2.4.5"
When writing test classes and using the line
[assembly: Xunit.TestFramework("Elastic.Xunit.Sdk.ElasticTestFramework", "Elastic.Xunit")]
, none of the tests (even the non Elastic tests) are discovered. I'm sure it's something simple I'm missing, but I can't find anything. I've used Visual Studio 2019 and the command line to no avail.It's almost an exact copy of the ExampleMinimal.