mirage / alcotest

A lightweight and colourful test framework
ISC License
451 stars 80 forks source link

Is there a way to skip tests based on an ad-hoc run-time condition? #293

Open aantron opened 3 years ago

aantron commented 3 years ago

For example, OUnit has https://gildor478.github.io/ounit/ounit2/index.html#skip-and-todo-tests. Lwt's ad-hoc tester has ~only_if arguments for both individual tests and entire test suites.

craigfe commented 3 years ago

Sadly, there is not. The closest that Alcotest gets to this is the `Quick/`Slow tags on tests.

The need for a more generalised form of that feature is tracked by https://github.com/mirage/alcotest/issues/124. I have a WIP draft of an "Alcotest 2.0" API that aims to let users attach arbitrary metadata to tests and then pass filters over that metadata at run-time, which I hope will meet this need.

MisterDA commented 1 year ago

This has been (partially?) fixed with #368, released in Alcotest 1.7.0, with Alcotest.skip.

let test_only_on_windows () =
  if Sys.os_type <> "Win32" then Alcotest.skip () else ();
  (* actual test code *)