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 8177951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:38:56+00:00 2026-06-06T23:38:56+00:00

I have some functionality withing a script file, setup.fsx I would like to test

  • 0

I have some functionality withing a script file, setup.fsx
I would like to test those.
xUnit and the likes needs the functions to be tested to be part of the assembly.

So I am thinking of renaming my script from setup.fsx to setup.fs extension, then loading it from another script file. But then my script depends on

#r "System.Xml"
#r "System.Xml.Linq"

which I would then have to specify in the calling script (away from where the dependency actually arises)

Are there anyway to integrate tests based on scripts in the xUnit worflow ?
What organization is suggested for writing tests for script files ?

(may be we need a visual studio extension for tests in scripts and not in assembly..)

  • 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-06T23:38:57+00:00Added an answer on June 6, 2026 at 11:38 pm

    Even if you just add fsx script to Visual Studio, you can still compile setup.fsx into a normal project together with other (possibly fs) files, so you should be able to keep the script as a normal script file in Visual Studio and, at the same time, reference it from a project or from a command line tool that builds your tests.

    I tried doing that with the following test.fsx file:

    module Demo
    #r "System.Xml.Linq.dll"
    open System.Xml.Linq
    
    let test () = 
        let d = XDocument(XElement(XName.Get("foo")))
        d.ToString()
    

    You definitely need some module Name declaration at the beginning (so that you can access functions from other files), but otherwise it can be any fsx file. The other file that I used was test.fs:

    module Main
    open Demo    
    test() |> printfn "%A"
    

    This is just for testing, but here you could write your unit tests. If you compile the files with the following command, you get standard assembly that you could pass to xUnit (note, the compiler can pick the #r tag from test.fsx, we do not have to write the reference explicitly):

    fsc.exe --target:library test.fsx test.fs
    

    I think you could get the same configuration in Visual Studio if you add a library project and then manually add link to the file (which can point to a file elsewhere in your solution structure) using something like this in the fsproj file:

    <Compile Include="..\Eslewhere\In\Your\Project\Tree\File.fsx">
      <Link>File.fsx</Link>
    </Compile>
    

    Note that when you add fsx file using “Add Item”, it is marked as “Include” but not as “Compile”, so it does not get compiled as part of the project. The above should include it in the project and it should tell the compiler to include it in the compiled assembly too.

    Warning: that said, I think it might be better to test just compiled dll files using standard unit tests. If you want to test fsx files, I would just add a couple of lines as tests at the end and run them by hand (select, Alt+Enter). The reason is that fsx files are supposed to be changed quite often and so having too solid testing may limit your flexibility. On the other hand, once code gets more solid, it makes sense to move it to a dll file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some useful wpf buttons to test some functionality. It would be good
I would like to have some functionality by which if I write <textarea maxlength=50></textarea>
I have some functionality that needs to be async in my C# app. It's
I have some functionality that I need in all my classes which derive from
Many mobile web browsers have some default functionality on image hold. For example, user
In my WPF application I have some drawing functionality. I have solved this using
Here's what i'm trying to do: I what to have some FTP functionality in
In C#, I am developing several Windows Services which have some standard functionality so
I have some drag and drop functionality I am using in an xceed grid.
I have a question about some functionality I'm trying to add to my jQuery

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.