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

CLIApp Testrunner Mk2 #120

Merged
merged 3 commits into from
Dec 26, 2016
Merged

CLIApp Testrunner Mk2 #120

merged 3 commits into from
Dec 26, 2016

Conversation

jaa127
Copy link
Contributor

@jaa127 jaa127 commented Dec 25, 2016

This PR implements cli-testrunner Mk2 which makes TestRunner behave truly like Scalatest's FunSuite (all asserts available).

This is done by extending FunSuiteLike with TestRunner as trait. It is now possible to write testrunner tests normally as scalatest's Funsuite tests, ignore them, and most importantly, use normal FunSuite asserts. Especially this is handy with assertThrows, which lets us to test error paths and constraints with specific asserts. DirSuite implementation: 7caad6b

Example usage of DirSuite: 7f5c91d
These added error path tests found one corner case input handling bug (bugsInputError/pe01.ledger), which is currently ignored, and one AssertionError (AssertionError/ae01.ledger) with invalid input.

Travis has nice example of test run's output: Travis-166

…ite)

This is a combination of TestRunner and FunSuiteLike as DirSuite trait.

This lets you to write testrunner tests normally as scalatest's
Funsuite tests, ignore them, and most importantly, use normal FunSuite
asserts.  Especially this is handy with assertThrows, which lets us
to test error paths and constraints with specific asserts.

DirSuite trait provides following extra testrunner-methods:
 - testDirSuite
 - ignoreDirSuite

DirSuite tests can be defined as:

  testDirSuite("../tests", ".*/sclT[0-9]+(-.*)$") { args: Array[String] =>
    assertResult(CLIApp.SUCCEEDED){
      CLIApp.mainStatus(args)
    }
  }

  testDirSuite("../tests", ".*/SettingsError$") { args: Array[String] =>
    assertThrows[SettingsError]{
      CLIApp.run(args)
    }
  }

There are also changes to main app outside test-scope to better support
testability and fix few warts.
These tests found one corner case input handling bug
(bugsInputError/pe01.ledger), which is currently ignored,
and one AssertionError (AssertionError/ae01.ledger) with
invalid input.
@coveralls
Copy link

Coverage Status

Coverage increased (+2.4%) to 71.331% when pulling 7f5c91d on jaa127:testrunner-mk2 into 0aa0908 on hrj:master.

@hrj
Copy link
Owner

hrj commented Dec 25, 2016

Hey, I wonder why this error happens now:

[info] - /home/travis/build/hrj/abandon/tests/sclT0005-filters/f060.conf

Internal Assertion Error (please report a bug):assertion failed: More than one account with unspecified amount: List(Post(Expenses:E01,None,None), Post(Assets:A01,None,None))

(I am travelling so I am not able to review in detail)

@jaa127
Copy link
Contributor Author

jaa127 commented Dec 25, 2016

=), I wondered same thing when I saw it first time, but everything is good. It is not filter-test which is producing AssertError, but the next test, which is testing that CLIApp errors (and producing AssertionError).

So it happens because funtest prints first test output, and then the name of current test. So filter test is passing, it's result is printed (in green) then is started AssertError test, which produce that line, and lastly name of that AssertError test (it is supposed to error, only problem is that it is AssertError).

The actual test-result line for that AssertionError is on line Travis-166#L922

So everything is good and all tests are passing. Scalatest prints test output that way, because it has to first execute test, so it can report correctly test output with single line. It is kind of confusing, especially with those error tests. Maybe there is an option to print Starting test ... Ending test - Passing or something similar, dunno.

On the other hand, when test is falling there is big red text which is saying that test is falling and all tests arguments are also printed on output, so test failure is really obvious when there is one.

Error path output code:
7caad6b#diff-dd8291f857d56ee0cb7aad158e1e2acaR108

@hrj hrj merged commit 6e13158 into hrj:master Dec 26, 2016
@hrj
Copy link
Owner

hrj commented Dec 26, 2016

Cool; thanks for the explanation! Merged.

By the way, what does Mk2 stand for?

@jaa127
Copy link
Contributor Author

jaa127 commented Dec 26, 2016

Thanks, Mk2 is kind of pun - all fine products have mark II variant. =D

@jaa127 jaa127 deleted the testrunner-mk2 branch December 26, 2016 07:58
@hrj hrj modified the milestone: Next release Jan 27, 2017
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

Successfully merging this pull request may close these issues.

None yet

3 participants