Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7959423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:34:15+00:00 2026-06-04T04:34:15+00:00

We are using the wonderful FSUnit for our unit testing. This works fine, except

  • 0

We are using the wonderful FSUnit for our unit testing. This works fine, except the bodies of our tests insist on using full F# syntax (with ‘in’ at the end of each line etc.) instead of #light syntax. For example:

module MyTests

open System
open NUnit.Framework
open FsUnit
open MyModule

[<TestFixture>] 
type ``Given a valid file`` () =

    let myFile = createSomeFile()

    [<Test>] member x.
     ``Processing the file succeeds`` () =
        let actual = processFile myFile in
        actual |> should be True

Note the ‘in’ at the end of the first line of the test. Without that, the test won’t compile – which is fine for short tests but is becoming a pain for longer test methods. We’ve tried adding an explicit #light in the source but that seems to make no difference. This is part of a large project with many modules, all of which – other than the test modules – are happily using light syntax (without any explicit #light). What’s triggering full syntax in the test modules?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T04:34:16+00:00Added an answer on June 4, 2026 at 4:34 am

    You need to use a bit different indentation when writing members of the class. The following should be fine:

    [<TestFixture>]  
    type ``Given a valid file`` () = 
        let myFile = createSomeFile() 
    
        [<Test>] 
        member x.``Processing the file succeeds`` () = 
            let actual = processFile myFile
            actual |> should be True 
    

    The first problem is that the name of the member should be indented further than . and the second problem is that the body of the member should be indented further than the member keyword – in your version, the keyword is written after [<Test>] so it would work if you indented the body further.

    Adding in solves the problem, because that’s telling the compiler more explicitly how to interpret the code (and so it does not rely on indentation rules).

    Aside – with some unit testing frameworks, it is also possible to use module which gives you a bit lighter syntax (but I’m not sure how that works if you need some initialization – i.e. to load a file):

    [<TestFixture>]  
    module ``Given a valid file`` = 
        let myFile = createSomeFile() 
    
        [<Test>] 
        let ``Processing the file succeeds`` () = 
            let actual = processFile myFile
            actual |> should be True 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi guys I'm using this wonderful class here to do a bit of code
Python has this wonderful way of handling string substitutions using dictionaries: >>> 'The %(site)s
I am using this wonderful bit of code created by jackreichert . This in
I am using an adaptation of Steve Sanderson's wonderful MVC Integration Testing Framework .
im using linux with gedit which has the wonderful habit of creating a temp
I am using Eric Hynd's wonderful multiselect plug in to populate a couple of
I am currently using swfupload to upload my files and it works wonderfully, but
using (var file_stream = File.Create(users.xml)) { var serializer = new XmlSerializer(typeof(PasswordManager)); serializer.Serialize(file_stream, this); file_stream.Close();
Using Flex 3, I would like to take an image snapshot such as this:
We have a wonderful ASP.NET MVC 2 web application using MS SQL 2008 and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.