Skip to content
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

Skippable tests #307

Open
marionebl opened this issue Jun 15, 2019 · 3 comments
Open

Skippable tests #307

marionebl opened this issue Jun 15, 2019 · 3 comments

Comments

@marionebl
Copy link
Contributor

marionebl commented Jun 15, 2019

While working #306 I noticed that it might be beneficial for learners to skip single tests, enabling a workflow where learners implement and enable one test after the other (as seen e.g. on the Rust and F# track)

Also skipping all tests by default might improve the overall track setup as executing dune runtest from the track root can serve as a basic sanity check for all exercises and test harnesses.

An example of how this might look like can be found here

brainpower-org/ocaml-exercism-cubicle/acronym/test.ml#L4-L6

I also thought it might be nice to have a CI step that copies examples.ml and runs the (then enabled) unit tests against it. I'm not sure what the best way to do this would be, thoughts?

I tried to contributes this in the test-generator templates but failed to compile the test-generator.

@sshine
Copy link
Contributor

sshine commented Jun 24, 2019

The main drawback of commenting out tests by default is that lazy students will get the impression that their program works because they haven't enabled all tests. At work we have a BAIL_ON_FAIL=1 parameter that, when set, will stop on the first test that fails. Would it not be preferrable to achieve the same workflow of "one test at a time", but avoid manually commenting in tests?

This is handled in the Haskell track with HSpec's configFastFail = True.

I wonder if OUnit2 has an equivalent.

It doesn't look like it.

@sshine
Copy link
Contributor

sshine commented Jun 24, 2019

I thought that maybe

val run_test_tt_main : ?exit:(int -> unit) -> test -> unit

means that we can exit the test suite given a failure.

But trying

 let () =
  run_test_tt_main ("connect tests" >::: tests)
    ~exit:(fun i ->
        print_endline ("I got " ^ string_of_int i ^ "!");
        exit i
    )

still runs all tests.

So I don't think so.

@marionebl
Copy link
Contributor Author

I thought about a solution along these lines:

let ae ?(skip=false) exp got _test_ctxt  =
  skip_if skip "Skipped";
  assert_equal exp (got ()) 

let () =
  run_test_tt_main ("tests" >::: [
    "skipped - would fail" >:: ae ~skip:true true (fun _ -> false);;
    "not skipped - succeeds" >:: ae ~skip:false true (fun _ -> true);;
  ])

Running this creates output like this:

.S
Ran: 2 tests in: 0.10 seconds.
OK: Cases: 2 Skip: 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants