pgrange/bash_unit

[feature request] Add a `pending` function

Pamplemousse opened this issue · 3 comments

It could be useful to be able to write pending tests.

Use cases:

  • express the intent to write a test later (a.k.a "Not yet implemented")
  • mark a work in progress without commenting (an therefore hiding) a test

Example of usage:

# written has
test_we_need_to_think_about() {
  pending "This needs to be implemented"
}

test_is_not_working() {
  assert "./script/going/wrong"
  pending "Investigating"
}

# displayed has
Running test_we_need_to_think_about... PENDING ✗
This needs to be implemented

Running test_is_not_working... PENDING ✗ 
Investigating

Thank you for your feature request.

I am wandering, does the test suite fail in presence of pending tests or does it succeed ?

A test itself, does it continue after the call to pending or does it stop immediately ?

Also, do you have references to xunit testing framework implementing pending so we may look at an implemented specification ?

It depends of what "kind of" pending you want to implement.

Some libraries make their pending expect a failing test, therefore fails if the test marked as pending succeeds.
In such a case, you would want to read the whole test.

I was thinking specifically about rspec at first.

It seems that Java and C# worlds uses "annotations" to mark tests to be disabled (see https://github.com/ttsui/pending or https://msdn.microsoft.com/en-us/library/ms182457(v=vs.100).aspx). But the behaviour seems similar.

I am thinking of using a prefix in function name to identify pending tests.
That way, you can already use it in your tests and they will be ignored (just ignored) and then in a next release of bash_unit, they will also be ignored but will appear as so in bash_unit output.

That may seem quite a naive implementation (and it probably is) but I do not want to introduce too much complexity in bash_unit.

With your previous usage exemple it would be something like:

pending_we_need_to_think_about() {
  assert true
}

pending_is_not_working() {
  assert "./script/going/wrong"
}

# displayed has
Running test_we_need_to_think_about... PENDING ✗

Running test_is_not_working... PENDING ✗