fspec icon indicating copy to clipboard operation
fspec copied to clipboard

FSpec command line runner can't find my tests

Open amirci opened this issue 10 years ago • 4 comments

I am trying to run an example from the command line but spec runner does not find any tests.

amirci avatar Feb 13 '15 07:02 amirci

My best guess from your description is that you need to assign the examples to a value named specs

let specs =
    describe "My feture" [
        it "works" ...
    ]

This is important for two reasons. The first is that the describe function does not actually change any state. In returns a hierarchical structure containing the actual tests. So we need to store it somewhere.

Secondly, F# don't actually execute code in modules, until you actually access the module, so I needed some convention to be sure that the I could trigger the execution of the module code, and in this case, it is iterating through modules, and get the value specs

stroiman avatar Feb 13 '15 07:02 stroiman

Casing is important! lowercase specs

stroiman avatar Feb 13 '15 07:02 stroiman

Actually I just copied the code from one of the tests...

module MyModule = 
    let specs =
        describe "Some component" [
            describe "Some feature" [
                context "In some context" [
                    it "has some specific behaviour" (fun _ ->
                        ()
                    )
                    it "has some other specific behavior" (fun _ ->
                        ()
                    )
                ]
                context "In some other context" [
                    it "has some completely different behavior" (fun _ ->
                        ()
                    )
                ]]]

What I have seen so far is that when selecting the types to run FSharpType.IsModule fails.

amirci avatar Feb 17 '15 05:02 amirci

Found it! It's a F# runtime issue.

FSpec has configure 4.3.0 and my project 4.3.1. That's why MyModule does not get selected to be run.

I'll research a bit more to see how can be fixed.

amirci avatar Feb 17 '15 19:02 amirci