Open
Description
Describe the bug
Hi there! Thank you for working on this. I jumped to try this stuff right away once I read the article here: https://devblogs.microsoft.com/dotnet/mtp-adoption-frameworks/. Unfortunately it looks it doesn't work. I have "'EntryPointAttribute' attribute must be the last declaration in the last file ".
Steps To Reproduce
- mkdir tests
- cd tests
- dotnet new console -lang "F#"
- Paste fsproj stuff from the article. Here it is;
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<EnableExpectoTestingPlatformIntegration>true</EnableExpectoTestingPlatformIntegration>
<OutputType>Exe</OutputType>
<TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="YoloDev.Expecto.TestSdk" Version="0.15.0" />
</ItemGroup>
<ItemGroup>
<Compile Include="Test.fs" />
</ItemGroup>
</Project>
- Adjust the file name that was generated, here I have Test.fs.
- Run dotnet build.
- Experience the error
Files in libraries or multiple-file applications must begin with a namespace or module declaration, e.g. 'namespace SomeNamespace.SubNamespace' or 'module SomeNamespace.SomeModule'. Only the last source file of an application may omit such a declaration.
- It is the last source file but fine. Let's add the module. So we have sth like this:
module Tests
open Expecto
let tests =
testList "Calculator Tests" [
test "Add function returns sum" {
let result = 4
Expect.equal result 3 "Expected sum to be 3"
}
]
[<EntryPoint>]
let main argv =
runTestsWithArgs defaultConfig argv tests
- Experience the
The value or constructor 'runTestsWithArgs' is not defined. Maybe you want one of the following: runTestsWithCLIArgs runTestsWithCLIArgsAndCancel
error. - change
runTestsWithArgs defaultConfig argv tests
to
runTestsWithCLIArgs [] argv tests
- Experience
A function labeled with the 'EntryPointAttribute' attribute must be the last declaration in the last file in the compilation sequence.
Expected behavior
It works.
Actual behavior
Errors.
Additional context
I am using Ubuntu. Also If you will remove EnableExpectoTestingPlatformIntegration attribute then it compiles. When I type dotnet run, it actually runs the tests. All in all Rider doesn't detect the tests, so the test explorer is empty.