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

SkippableTheory and empty source input from MemberData will produce exception #28

Closed
kenjiuno opened this issue Oct 25, 2022 · 2 comments

Comments

@kenjiuno
Copy link

ParserTest.cs

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using Xunit;

namespace SkippableTheoryAndMemberDataAndEmpty
{
    public class ParserTest
    {
        [SkippableTheory]
        [MemberData(nameof(ProvideFiles))]
        public void TestFile(string file)
        {
            File.ReadAllText(file); // test this in own code...
        }

        public static IEnumerable<object[]> ProvideFiles()
        {
            foreach (var file in Directory.GetFiles(".", "*.file-extension"))
            {
                yield return new object[] { file };
            }
        }
    }
}
dotnet test

  Determining projects to restore...
  All projects are up-to-date for restore.
  SkippableTheoryAndMemberDataAndEmpty -> H:\Proj\SkippableTheoryAndMemberDataAndEmpty\SkippableTheoryAndMemberDataAndEmpty\bin\Debug\net6.0\SkippableTheoryAndMemberDataAndEmpty.dll
Test run for H:\Proj\SkippableTheoryAndMemberDataAndEmpty\SkippableTheoryAndMemberDataAndEmpty\bin\Debug\net6.0\SkippableTheoryAndMemberDataAndEmpty.dll (.NETCoreApp,Version=v6.0)
Microsoft (R) Test Execution Command Line Tool Version 17.3.0 (x64)
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
[xUnit.net 00:00:00.47]     SkippableTheoryAndMemberDataAndEmpty.ParserTest.TestFile [FAIL]
  Failed SkippableTheoryAndMemberDataAndEmpty.ParserTest.TestFile [< 1 ms]
  Error Message:
   System.InvalidOperationException : The test method expected 1 parameter value, but 0 parameter values were provided.


Failed!  - Failed:     1, Passed:     0, Skipped:     0, Total:     1, Duration: < 1 ms - SkippableTheoryAndMemberDataAndEmpty.dll (net6.0)

The exception message

System.InvalidOperationException : The test method expected 1 parameter value, but 0 parameter values were provided.

I wonder why...

repo https://github.com/kenjiuno/SkippableTheoryAndMemberDataAndEmpty

@AArnott
Copy link
Owner

AArnott commented Oct 26, 2022

So is the idea that GetFiles produced an empty list? If so, why do you expect something other than an error? Theories are generally expected to run with at least 1 test case, and usually more.

@kenjiuno
Copy link
Author

Thanks for reply.
And sorry it was my misunderstand that SkippableTheory can work with empty list.
This is enough that this not problem of Xunit.SkippableFact. Sorry for taking your time.
I'll check more about Xunit itself.

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

No branches or pull requests

2 participants