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

Overloaded test methods result in InvalidOperationException #392

Closed
pranavkm opened this issue Jan 27, 2017 · 5 comments
Closed

Overloaded test methods result in InvalidOperationException #392

pranavkm opened this issue Jan 27, 2017 · 5 comments
Assignees

Comments

@pranavkm
Copy link

Description

We were migrating an existing project.json based xunit test project to MSBuild. One of the test classes had a overloaded method - one as a Fact with no arguments and the other a Theory with InlineData. Once migrated, the test runner fails while running one of the overloaded method.

Steps to reproduce

What steps can reproduce the defect?

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp1.0</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0-*" />
    <PackageReference Include="xunit.runner.visualstudio" Version="2.2.0-*" />
    <PackageReference Include="xunit" Version="2.2.0-*" />
  </ItemGroup>
</Project>
using Xunit;

namespace ConsoleApp
{
    public class Test
    {
        [Fact]
        public void TestMethod()
        {
            Assert.True(true);
        }

        [Theory]
        [InlineData(true)]
        public void TestMethod(bool value)
        {
            Assert.True(value);
        }
    }
}

Expected behavior

Overloaded tests work

Actual behavior

Starting test execution, please wait...
Error Message:
Failed   ConsoleApp.Test.TestMethod(???: True)
 System.InvalidOperationException : The test method expected 0 parameter values, but 1 parameter value was provided.

Passed   ConsoleApp.Test.TestMethod

Total tests: 2. Passed: 1. Failed: 1. Skipped: 0.

Environment

Please share additional details about the test environment.
dotnet --info:

.NET Command Line Tools (1.0.0-rc3-004522)

Product Information:
 Version:            1.0.0-rc3-004522
 Commit SHA-1 hash:  4e0b465093

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.14393
 OS Platform: Windows
 RID:         win10-x64
@codito
Copy link
Contributor

codito commented Jan 28, 2017

Appears to be a known limitation in xunit adapter. See xunit/xunit#1042.

@NTaylorMullen
Copy link
Member

NTaylorMullen commented Jan 28, 2017

Did this work in project.json world because the xunit there wasn't using the visual studio runner? If so, did it do something different when run in VS?

@pranavkm
Copy link
Author

@NTaylorMullen - yeah both overloads were working with project.json.

@sbaid sbaid added the external label Feb 2, 2017
dougbu pushed a commit to aspnet/Mvc that referenced this issue Mar 1, 2017
- thanx to @NTaylorMullen for initial conversion
  - e.g. AssemblyInfo.cs files were already minimized or removed :)
- allow `>=` RC3 CLI's to build and run MVC
- work around several dotnet migration issues; see #5482
- disable full .NET Framework runs of functional tests; see #5873
- remove `Microsoft.DotNet.InternalAbstractions` and `System.Xml.XmlDocument` dependencies
- remove project.json (!!), *.xproj, .notest, and web.config files

Redo earlier changes:
- apply test migration to .NET 4.5.2 in *.csproj world
  - see 63507c8 for previous, project.json work
- apply dependency version downgrade from 0097e40 in *.csproj world

Make other test-related changes:
- make Microsoft.AspNetCore.Mvc.TestDiagnosticListener a regular class library
- add support for `/p:GenerateBaselines=true` for functional and Razor.Host tests
- separate `GetCSharpTypeName_ReturnsCorrectTypeNames_ForOutParameter()` test
  - work around inability to deserialize a odd `ref` type
  - xUnit and vstest now serialize / deserialze test data more often
- skip poor test mentioned in #5768
- work around microsoft/vstest#392
  - rename tests to avoid duplicates
- work around microsoft/vstest#419
  - set up created `AppDomain`s with current `ApplicationBase`
@codito codito added the exp: cli label Apr 4, 2017
@Faizan2304
Copy link
Contributor

Faizan2304 commented May 25, 2017

This is known xunit issue: xunit/xunit#1042 and unfortunately there is no solution for it :(

@NTaylorMullen
Copy link
Member

I'm shocked; how did this work in project.json land? It used xunit as well.

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

5 participants