-
-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to show test results in interactive #365
Comments
You have to create a logger: open Expecto.Logging
open Expecto.Logging.Message
let logger = Log.create "FSI"
logger.info (eventX "Hi") |
@haf Sorry, but still not get this. For example with the following I was expecting that a verbose print should be visible in the FSI: runTestsWithCLIArgs [ CLIArguments.Debug; CLIArguments.Sequenced ] [||] However, whether or not I add the CLIArguments the print out just shows:
How can I tell Expecto to use the logger? Or do I need to manually insert a logging message in each test? I use VSCode on a Macbook. |
It's still a bit scrappy, but I wrote these run methods for better interactive support. They capture the logs normally printed to the console and return them as a string from the run method. There's one with ANSI coloration and one without module Tests =
let private literateOutputWriter (outputBuilder: StringBuilder) (text: (string*ConsoleColor) list) : unit =
let colorizeLine (text, color) = ColourText.colouriseText color text
let sbAppend (builder: StringBuilder) (text: string) =
builder.Append(text)
text
|> List.iter (colorizeLine >> (sbAppend outputBuilder) >> ignore)
let private colorlessOutputWriter (outputBuilder: StringBuilder) (text: (string*ConsoleColor) list) : unit =
text
|> List.iter (fun (text, color) ->
outputBuilder.Append(text)
|> ignore)
let run_ReturnLogs cliArgs args tests =
let outputBuilder = StringBuilder("")
Global.initialise
{ Global.defaultConfig with
getLogger = fun name ->
Expecto.Logging.LiterateConsoleTarget(
name = [|"boi"|],
minLevel = Expecto.Logging.LogLevel.Info,
outputWriter = (literateOutputWriter outputBuilder)) :> Expecto.Logging.Logger
}
Tests.runTestsWithCLIArgs cliArgs args tests |> ignore
outputBuilder.ToString()
let run_ReturnLogs_NoColor cliArgs args tests =
let outputBuilder = StringBuilder("")
Global.initialise
{ Global.defaultConfig with
getLogger = fun name ->
Expecto.Logging.LiterateConsoleTarget(
name =[|"boi"|],
minLevel = Expecto.Logging.LogLevel.Info,
outputWriter = (colorlessOutputWriter outputBuilder)) :> Expecto.Logging.Logger
}
Tests.runTestsWithCLIArgs cliArgs args tests |> ignore
outputBuilder.ToString() |
How can I print the test results in a nice way in the interactive? I tried something like:
But this results in garbled output in the interactive. Is there an easy way to accomplish this?
The text was updated successfully, but these errors were encountered: