Skip to content

Commit 4701026

Browse files
authored
Add examples (#12)
* added examples; moved to xunit.v3 * changelog update * added README link * added MTP entry to global.json
1 parent 8308611 commit 4701026

11 files changed

Lines changed: 71 additions & 17 deletions

File tree

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# CHANGELOG
22

3+
## 1.0.10
4+
5+
### added
6+
7+
* documentation examples
8+
9+
### changed
10+
11+
* moved to xunit.v3
12+
313
## 1.0.9
414

515
* changed global and target framework to net10

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The source file can contain directives to reference libraries and to influence t
1515

1616
Because of a) concerns of parts of the F# community about having two similar tools (`dotnet fsi script.fsx` and `dotnet runfs app.fs`) and b) missing "market pull", I have currently no further plans for this project.
1717

18-
The tool is still available as dotnet tool and can be useful especially for ad-hoc testing of library projects.
18+
The tool is still available as dotnet tool and can be useful especially for [ad-hoc testing of library projects](docs/examples/testing/README.md).
1919

2020
## Usage
2121

docs/examples/testing/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Using runfs for library testing
2+
3+
## Explorative testing
4+
5+
Just create an ad-hoc driver file (see example file `explore.fs` in this directory), add a project reference and start testing your library API by running `dotnet runfs explore.fs`.
6+
7+
## Unit test development / fixes
8+
9+
Rather than building a test project, discovering the tests, selecting the one you are interested in and running it, you just add the project reference and the test framework package reference to the test file you are interested in (see example file `tests.fs`, using xunit.v3) and run it with runfs (here: `dotnet runfs tests.fs`).
10+

docs/examples/testing/explore.fs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#r_project "D:/fsharp/projects/div/Runfs/docs/examples/testing/mylib/mylib.fsproj"
2+
3+
open Mylib
4+
5+
printfn $"Hello {x}"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<Project>
2+
<PropertyGroup>
3+
<UseArtifactsOutput>true</UseArtifactsOutput>
4+
</PropertyGroup>
5+
</Project>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module Mylib
2+
3+
let x = 42
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net10.0</TargetFramework>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<Compile Include="Library.fs" />
9+
</ItemGroup>
10+
11+
</Project>

docs/examples/testing/tests.fs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module Mylib.Tests
2+
3+
#r_package "xunit.v3.mtp-v2@3.2.2"
4+
#r_project "mylib/mylib.fsproj"
5+
6+
#nowarn 988
7+
8+
open Xunit
9+
open Mylib
10+
11+
[<Fact>]
12+
let test1 () =
13+
Assert.Equal(x, 42)

global.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@
33
"version": "10.0.100",
44
"rollForward": "latestMinor",
55
"allowPrerelease": false
6+
},
7+
"test": {
8+
"runner": "Microsoft.Testing.Platform"
69
}
7-
}
10+
}

src/Runfs/Runfs.fsproj

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<!-- General -->
44
<AssemblyName>Runfs</AssemblyName>
5-
<Version>1.0.9</Version>
5+
<Version>1.0.10</Version>
66
<Description>"dotnet run app.cs" functionality for F#.</Description>
77
<Copyright>Copyright 2025 by Martin521</Copyright>
88
<Authors>Martin521 and contributors</Authors>
@@ -15,12 +15,15 @@
1515
<PackAsTool>True</PackAsTool>
1616
<ToolCommandName>runfs</ToolCommandName>
1717
<PackageReleaseNotes>
18-
## 1.0.9
18+
## 1.0.10
19+
20+
### added
21+
22+
* documentation examples
1923

2024
### changed
2125

22-
* changed global and target framework to net10
23-
* updated README
26+
* moved to xunit.v3
2427
</PackageReleaseNotes>
2528
<PublishRepositoryUrl>true</PublishRepositoryUrl>
2629
<PackageIcon>

0 commit comments

Comments
 (0)