• (nodebb)

    The frist goal of unit testing is to get the code coverage percentage as high as possible, right?

  • Registered (unregistered)

    On the plus side, they used declarative code in their unit test and didn't use a prohibited loop to create all unit test cases.

  • my name (unregistered) in reply to Dragnslcr

    yepp, code coverage is the goal, if it tests sensible situations is not required

  • (nodebb)

    That doesn't look like xUnit to me, I guess good old nUnit. And no Dragnslcr, code coverage is about covered execution branches, that method doesn't have one. It's just wasting CPU circles cause nUnit is also known for not being very efficient.

    Addendum 2024-06-18 06:56: Nvm, the article talks about SQL-construction, so I guess you have a ton of actual execution branches there.

  • (nodebb)

    This test ensures that connection to the database is successful, there is enough disk space on the database server, and that INSERT statement is generated correctly. Very beneficial!!

  • Hrolf (unregistered) in reply to Mr. TA

    Exactly! Plus we're ensuring that the database fields still accept Boolean values! Who knows what those sneaky DBAs might try to pull?

  • TheCPUWizard (unregistered)

    Pre-Setting for as the method is developed to make sure that none of the combinations throw an exception.

  • Sauron (unregistered)

    I'm glad they didn't add FileNotFound as a third boolean value in that codebase. Imagine the number of test cases there would be!

  • Naomi (unregistered) in reply to Registered

    On the plus side, they used declarative code in their unit test and didn't use a prohibited loop to create all unit test cases.

    In Javaland, we'd write a method that generates the permutations, then put @MethodSource("theNameOfThatMethod") on the test case. It still keeps the looping separate from the testing, and the test report will consider them separate cases (so if true, false, true fails, that one in particular will be highlighted), just like any argument source. I don't see any reason to prefer manually enumerating the cases.

    If the above comment was ironic, ignore this, I suppose.

  • Erwin (unregistered)

    Coverage can't be that good without testing for combinations with the boolean value FILE_NOT_FOUND

  • L (unregistered)

    is it just me or the test method is actually empty?

  • (nodebb) in reply to L

    looks empty for me, too

  • (nodebb)

    For a job that lives and dies on understanding what you are doing and why, there sure are a lot of people who simply don't. Not even a little bit.

  • dusoft (unregistered)

    If only we could generate random combinations using a function. Oh, wait...

  • (nodebb)

    This does bring up a point though. In a lot of cases, your app doesn't have individual functionality to test, it's based off of sending/reading some data and doing something with that. For example, at work we have an app which wraps a 3rd party DLL, and is entirely run off of JSON sent by the consuming application. So we have no good way to test this because it's all based around feeding it a json document, parsing that and passing it to the 3rd party DLL, and spitting out the results.

    We could mock json files for things, but that's a bit ridiculous IMHO.

  • Dr, Pepper (unregistered)

    Hey, I'm late to the party; but I don't have a problem with passing every possible combination of values to the test method. I WOULD expect there to be an assertion, so one of the values (the last one in each row) should be the expected result.

    By passing every possible combination of values, you absolutely ensure that the method being tested behaves as expected.

  • Abigail (unregistered)

    Despite the name "Update", it inserts a pile of permissions records.

    That by itself doesn't have to be bad. From the callers point of view, this may indeed update records, even if, behind the scenes, you're doing inserts.

  • Craig (unregistered) in reply to DocMonster

    There's nothing ridiculous about having internal unit tests for your json wrangling, though I would expect that most of the testing would end up being integration tests (as much as it can be tested through the third-party components).

Leave a comment on “All the Cases Covered”

Log In or post as a guest

Replying to comment #:

« Return to Article