Hi Gunnar - I am not sure how to get vs unit testing integrated, but here's an example of how to configure a vs F# project for nunit testing.

[link:natehoellein.blogspot.com]

Regards, Nate

By on 1/22/2008 4:56 PM ()

There is also an excellent article on DevHawk:

"Practical F# Parsing: Unit Testing"

[link:devhawk.net]

By on 1/25/2008 6:25 AM ()

The Xunit seems nice. But I need some more help. Mostly I will get this kind of error message
..error: Type 'Xunit.TrueException' in Assembly 'xunit, Version=1.0.0.1105, Cult
ure=neutral, PublicKeyToken=8d05b1bb7a6fdb6c' is not marked as serializable. in
SerializationException
when running tests. Even with very simple tests like with scripts below. Why?
The other common error I get is
error: Exception has been thrown by the target of an invocation. in TargetInvoca
tionException
Why?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#light
#r @"C:\Users\Gunnar\Documents\Visual Studio 2008\Projects\xunit\xunit.dll"
open Xunit 
[<Fact>]
let test_isGreater() =
    let a = 2
    let b = 3
    Assert.True( a > b )
... and some more interesting things. This is te code I try
#light
#R @"C:\Users\Gunnar\Documents\Visual Studio 2008\Projects\xunit\xunit.dll"
#R @"C:\Users\Gunnar\Documents\Visual Studio 2008\Projects\FSharp\Archetypes\Archetypes.dll"
open Xunit 
open Archetypes.Quantity
let a = {Amount = 2.0; Metric = "kg"}
let b = {Amount = 3.0; Metric = "kg"}
[<Fact>] let test_isGreater() = Assert.True( a <> b );;
[<Fact>] let test_isEqual() = Assert.Equal( a, a );;
[<Fact>] let test_isNotEqual() = Assert.NotEqual( a, b );;
[<Fact>] let test_isEqual1() = Assert.Equal( a, b );;
[<Fact>] let test_isNotEqual1()= Assert.NotEqual( a, a );;

If I comment out two last lines, then all works - three tests and all as expected. But if all 5 tests are active, then I got the following errormessage:

1
2
3
.error: Type 'Xunit.NotEqualException' in Assembly 'xunit, Version=1.0.0.1105, C
ulture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c' is not marked as serializable.
in SerializationException

Someone can explain why?
Regards
G

By on 1/28/2008 1:23 AM ()

Hi Gunnar - I get the same thing, but only on failing tests. It looks like it is a bug: [link:www.codeplex.com]

By on 1/28/2008 3:57 PM ()

Hi Gunnar,

Unit testing has been discusted here several times before the general conculsion seems to be that visual studio unit testing doesn't work with F#. No one seems to have given a concrete answer to it doesn't work but I strongly suspect it's because the project file uses an old visual studio format which isn't msbuild compatiable.

However, people have reported that they are able to use the NUnit test framework ([link:www.nunit.org]) without any problems, so most people just use that instead.

Cheers,
Rob

By on 1/21/2008 4:06 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper