• (disco)

    Well the last one is actually a brillant one.

    Now You know how to generate test code for virtually any percentage of real code by just writing a simple script (pseudocode):

    for (x = 0; x < maxtest; x+) { print "s = "";\n"; }

    As I said Brillant :smile:

  • (disco)

    That first one is really checking whether convertToRelativeDate produces consistent results. I've had the bad fortune to encounter classes where basic assumptions like that were not maintained, and they were horrible.

    Though I do have to ask “relative to what?” If it's relative to now, today, then fun happens if a midnight tick happens between the two calls…

  • (disco) in reply to dkf
    dkf:
    That first one is really checking whether convertToRelativeDate produces consistent results

    My first thought was that if convertToRelativeDate is using system epoch as the basis, the comparison is going to be very, very implementation dependent, and the output unpredictable.

    The second one reminds me of an old Soviet era joke. The Central Committee 5 year plan calls for shoe factories to turn out the maximum number of shoes, so State Shoe Factory No. 1 spends 5 years churning out baby shoes. For the next 5 years, therefore, the plan calls for factories to generate the maximum weight of shoes. So the factory turns out industrial boots with steel toecaps. The Central Committee thinks hard about this and somebody has a brlliant idea. "We'll tell them to produce the maximum value of shoes."

    A week later the purchasing manager of the factory starts looking for someone who can make solid gold hobnails.

  • (disco)

    That second one looks like a prima facie case of professional misconduct, or even fraud.

  • (disco) in reply to dkf

    It also calls the method on two different objects bpm and newBpm, which might not be the same.

  • (disco)

    It doesn’t hold a candle from this snippet

    I'm glad to see that the code is so generous. If that poor snippet had its candle withheld...

  • (disco)

    Of course, Salesforce only counts raw lines in code coverage, so repeating the s=''; multiple times a line doesn’t actually help anything.

    So they encourage the pay-per-line programming style, too?

  • (disco)

    So, where is bpm defined in the first snippet? How do we know it's the same as newBpm?

    Remy:
    so repeating the s=''; multiple times a line doesn’t actually help anything.
    So, either my browser displays things wrong, or there are a lot of `s=""` in the same line Oo

    Filed Under: Just saying

  • (disco) in reply to Kuro

    Also, what does this mean?

    Salesforce, you see, refuses to release code unless there’s 75% test coverage.

    How does it relate to the test? Were Alice and the contractor working for Salesforce?

    We have one giant line with a bunch of junk that doesn't do anything. What's the definition of "coverage" here? Remy's statement seems to imply that they're really talking about the test suite's LOC count.

    http://i.ytimg.com/vi/6zj5eyE1qUA/hqdefault.jpg

  • (disco) in reply to boomzilla
    boomzilla:
    Were Alice and the contractor working for Salesforce?

    I like to imagine that alice (maybe even @aliceif) was the entire salesforce, translating into the only person who bought the product. And she just refused to update buy more versions of the same software until the darn "coverage" had been fufilled. Since nobody understood what she meant by that, they just added random lines of nothing-code!

    Filed Under: Yeah, I am as lost as you. @Remy BITCHCOMPLAINEXPLAIN

  • (disco) in reply to boomzilla
    boomzilla:
    What's the definition of "coverage" here?

    Coverage for unit tests is typically measured as either percentage of statements executed or percentage of branches taken. Less common is percentage of functions entered or percentage of lines executed. Clearly the contractor assumed it was statement coverage, but Remy's statement points out it's lines covered.

    I believe the article is saying that the code you see was in the real code, tucked away in an unused function, so that writing one unit test that covers that function achieves 75% line coverage for the class.

  • (disco) in reply to Kuro

    Coverage ...?

    What's that?

  • (disco) in reply to Yamikuronue
    Yamikuronue:
    I believe the article is saying that the code you see was in the real code, tucked away in an unused function, so that writing one unit test that covers that function achieves 75% line coverage for the class.

    Ahhhh....that makes sense now. I looked at it as being another test.

  • (disco) in reply to aliceif

    Exactly. It's unknown. It's mysterious. It's something you would never think of ever needing. And thats exactly why you need it (and at least 75% of it, too! Otherwise, why even bother?)

    Filed Under: selling products seems too easy

  • (disco)

    Yes, that test simply calls the same method twice and confirms that the result of the first invocation is the same as the result of the second

    No it doesn't. The method is called on bpm and newBpm. Perhaps bpm is a known "working" implementation and the test only checks that the behavior of the new implementation is consistent with that of the old one.

  • (disco) in reply to tom103

    or there is some randomization and the test is to make sure the marginal error after decimation is zero.

  • (disco)

    I like how Remy's attempt to be funny breaks the formatting.<There's usually spacing oddness near the cornify script for some reason>

  • (disco)

    Of course, Salesforce only counts raw lines in code coverage, so repeating the s=''; multiple times a line doesn’t actually help anything.

    s/s;/s;\n/g FTFY.

    Also WTFTFY, LTPTFY, NYHTPTFY

  • (disco)

    But the first test actually checks method call result of bpm instance (likely declared somewhere else and containing reference/old implementation) against result of newBpm instance method call.

    And the second code has nothing with coverage.

  • Axel (unregistered)

    "At least there IS tests"?

  • Jamie S (unregistered)

    Fun fact, this page unrecoverably hangs Chrome for Android. You have to actually force close the app.

Leave a comment on “At Least There's Tests”

Log In or post as a guest

Replying to comment #:

« Return to Article