You should definitely be able to make good progress without an IDE. Even when I use an IDE, I still really only use it for stuff like Go To Definition, and autocomplete and type definitions when I hover on stuff. I use the command line dotnet
tool for managing projects & solutions, running tests, etc.
Now, the most oft recommended way to add tests is to have a separate project for the tests, which is pretty easy to setup. You can do dotnet new --list -lang f#
to see all of the F#-compatible project templates available on your machine. (Personally I would recommend NUnit or XUnit and not MSTest, since MSTest seems to me especially tailored for C#). Once you have multiple projects, you probably want a “solution” to contain them. So I can do
> dotnet new console -lang f# -n ProdProj
> dotnet new nunit -lang f# -n TestProj
> dotnet new sln -n MySolution
> dotnet sln add ProdProj
> dotnet sln add TestProj
> cd TestProj
> dotnet add reference ../ProdProj
(You probably have that first step already done for your console app). Now you can run dotnet build
(or dotnet build MySolution.sln
) to build both projects, or dotnet test
to run all the tests in the test project.
Sometimes I do like to have my tests in the same project, even if that’s not the recommended approach. What I would do in that case is take a look at the .fsproj that gets created when you run dotnet new nunit -lang f#
, and figure out what things to port over to your prod project. In this case, I think the important bits are
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="NUnit" Version="3.13.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.0.0" />
<PackageReference Include="coverlet.collector" Version="3.1.0" />
</ItemGroup>
Copy that into your console app, and now you can add tests directly into that project.
As far as resources go, I mostly just use the --help
docs with all the dotnet
commands, and then just run google searches on any nodes in the fsproj that I don’t know what they do. There might be some nice comprehensive docs on that stuff, but I don’t know them. If you’re searching for fsproj details, you might want to sometimes try searching with “csproj” instead as your search term, since there’s probably 100x more resources for csproj stuff online, and the two have very similar structures.