haf / expecto

A smooth testing lib for F#. APIs made for humans! Strong testing methodologies for everyone!
Apache License 2.0
663 stars 96 forks source link

Make the CLIArguments DU flags accept bool values #320

Open Alxandr opened 5 years ago

Alxandr commented 5 years ago

I just rewrote the YoloDev Expecto runner to use the new CLIArguments DU (instead of creating the config object ourselves), and one of the issues I ran into was that I wanted a different default for a flag in Expecto (specifically the fail on focused tests one). In order to make that work ATM, I have to keep track of whether or not the user overwrote it, instead of just doing something like this:

let args = (Fail_On_Focused_Tests true) :: userArgs

Folding the list would first set the value to true, then false. The way it works today, if you set the fail on focused tests value to true, there is no way to set it back to false (except to manually create the config object), hence the need for this workaround. I suggest that for the next major version of Expecto the DU is updated so that you're able to set all the values you should be able to set, to any value you should be able to set them (including the default).

haf commented 5 years ago

@Alxandr I understand it from an integrator's perspective, but from a user perspective, I only want flags that override default behaviour if possible. In Golang they do the same, but optionally let you provide booleans. That could be a way forward, but the Expecto-specific parser would have to be changed/improved.

Alxandr commented 5 years ago

I'm not saying you need to accept both from the command-line. Just make both as options using the API. Though, IMHO, accepting both from the command-line would also provide values to tools like Cake/Fake etc. that runs the tests as a command, but it's less important to my usecase.

haf commented 5 years ago

@Alxandr Thank you for clarifying. I'm going to leave it open here if someone wants to pick it up!