http://coldfusion.com logo
Join Slack
Powered by
# testing
  • a

    aliaspooryorik

    02/10/2022, 12:37 PM
    Can anyone think of a way to create a query object which has spaces in the column names? Backfilling tests on some old code before I refactor and it seems that cfspreadsheet when reading to a query object will handle spaces in column names which I want to mock.
    w
    a
    • 3
    • 10
  • b

    bockensm

    02/15/2022, 9:50 PM
    What's the proper way to use
    beforeeach
    in a given-when-then block in TestBox? It does not work like describe/it. I've tried it inside
    story
    and inside
    given
    and neither seem to do the trick.
    s
    a
    • 3
    • 11
  • a

    Adam Cameron

    02/23/2022, 11:12 AM
    How does one mock a function (not a method) with MockBox. IE: a function that's just in a library .cfm file instead of a method in a .cfc:
    Copy code
    <cfscript>
    // MyCoolLibrary.cfm
    
    
    function testMe() {
        if (avoidRunningMe()) {
            return "one fish"
        }
        return "two fish"
    
    }
    
    function avoidRunningMe() {
        // really slow or is destructive or has external dependencies or something
    }
    </cfscript>
    The library is just included when one wants to use it, eg like this:
    Copy code
    describe("Testing MyCoolLibrary", () => {
        include "MyCoolLibrary.cfm"
        it("checks testMe does the right thing", () => {
            // now I need to mock avoidRunningMe before calling testMe...?
        })
    })
    d
    • 2
    • 10
  • a

    Adam Cameron

    03/05/2022, 5:29 PM
    TestBox observation. And I'm wondering if this is a design bug. The
    beforeAll
    /
    afterAll
    lifecycle events are handled via defining a function of that name, and they run once per test bundle file (https://testbox.ortusbooks.com/in-depth/life-cycle-methods/bdd#beforeall). In other spec-driven testing frameworks, these lifecycle events are specific to the organisational block they are within; eg each
    describe
    block can have its own
    beforeAll
    handler, just like it can have a
    beforeEach
    handler. I've verified this on Jasmine, Mocha and RSpec. The docs on Jest are unclear, but I think they work the same way as TestBox. My own expectations are that TestBox ought to work the same as Jasmine, given TestBox is very very similar to it in many regards. And there's a good argument to be had that RSpec is the one to follow for one's expectations for this style of testing framework. Thoughts? (also ping @lmajano)
    • 1
    • 2
  • l

    lmajano

    03/07/2022, 9:11 PM
    Thanks for pointing that out @Adam Cameron I think this can be a feature to add. When I created TestBox, Jasmine didn’t support much life-cycle events (2013). They started introducing life-cycle events late 2014. Jasmine and Mocha where my initial inspir;ations. With that said, I see value in adding localized
    beforeAll()
    and
    afterAll()
    to
    describe(),story(),feature()
    blocks
    ✅ 1
    a
    • 2
    • 2
  • a

    Adam Cameron

    03/15/2022, 8:11 AM
    Hey if y'all have a moment, could you let me know how many unit tests you have for the app yer working on, and how long it takes TestBox to run them? NB: specifically unit tests. Not tests that hit external services / DBs etc. Just tests that are exercising algorithmic / business logic, not network connectivity. And specifically TestBox. Cheers.
    a
    r
    +5
    • 8
    • 15
  • r

    ryan

    03/22/2022, 8:05 PM
    I'm curious to know what folks are generally using for Performance Testing and Load Testing with Jenkins CI/CD. What are your thoughts regarding JMeter, K6, LoadView, or Gatling?
    b
    a
    +2
    • 5
    • 12
  • a

    Adam Cameron

    03/27/2022, 1:07 PM
    I wonder what you think about a probable design shortcoming in TestBox's SimpleReporter (ref: https://github.com/Ortus-Solutions/TestBox/blob/v4.5.0/system/reports/SimpleReporter.cfc#L71)
    l
    • 2
    • 15
  • a

    Adam Cameron

    03/28/2022, 8:00 AM
    @johnbarrett I keep a fairly close eye on this subchannel & am reasonably experienced with TDD / testing / TestBox so ping if you need help.
    • 1
    • 1
  • j

    jumpmaster

    04/15/2022, 5:48 PM
    This might be a dumb question, but is there a good way to test private methods with testbox? Or should I just stick to testing the public stuff and ignore all the in-between steps?
    d
    b
    a
    • 4
    • 6
  • a

    Adam Cameron

    04/17/2022, 12:51 PM
    This is not gonna be great to track down. Consider this test:
    Copy code
    it("fails if an exception is thrown", () => {
        expect(() => {throw "hi"}).notToThrow()
    })
    This should fail. On Lucee 5.3.7.48 it works fine. On Lucee 5.3.8.206 it doesn't work. IE: this test passes. It also passes if I use
    toThrow
    instead of
    notToThrow
    . I will try to track it back to a specific change in Lucee, but I suspect something woolly is going on in the TestBox code that makes it fragile. NB: that is just a distilled-down repro case. My actual case was with an expression that resulted in an exception, and I tried with various other expressions that caused exceptions. All behave the same:
    toNotThrow
    does not work. Ping @lmajano
    b
    • 2
    • 16
  • a

    Adam Cameron

    04/18/2022, 1:40 PM
    Probable TestBox bug. Just sanity checking it before I commit to raising it. I've seen what seems to be some incorrect behaviour in the
    notToThrow
    matcher. Here are some tests: https://gist.github.com/adamcameron/e1674e216bd8b759fb34e663fc8a6603
    b
    • 2
    • 11
  • a

    Adam Cameron

    05/11/2022, 8:17 PM
    https://twitter.com/adam_cameron/status/1524483558647214083
    👍🏻 1
    👍🏼 1
    👍 1
    j
    • 2
    • 2
  • a

    Adam Cameron

    05/12/2022, 9:09 PM
    https://blog.adamcameron.me/2022/05/cfml-adding-beforeeach-handlers-to-my.html
  • a

    Adam Cameron

    05/12/2022, 9:09 PM
    Didn't test that test string in my test, did I? HA
  • a

    Adam Cameron

    05/12/2022, 10:57 PM
    https://blog.adamcameron.me/2022/05/cfml-for-sake-of-completeness-heres.html
  • a

    Adam Cameron

    05/13/2022, 7:45 PM
    https://blog.adamcameron.me/2022/05/cfml-adding-aroundeach-to.html
    s
    • 2
    • 8
  • a

    Adam Cameron

    05/15/2022, 2:11 PM
    https://blog.adamcameron.me/2022/05/cfml-fixing-coupla-bugs-in-my-recent.html
    👍🏻 1
  • a

    Adam Cameron

    05/15/2022, 3:30 PM
    Bug raised for TestBox which is broken for the
    aroundEach
    case that I mention therein. https://ortussolutions.atlassian.net/browse/TESTBOX-351
  • a

    aliaspooryorik

    05/18/2022, 8:17 AM
    This is excellent stuff @Adam Cameron Take my karma already (if I could give any!)
    👍 1
  • a

    Adam Cameron

    05/23/2022, 7:48 PM
    Any reason what this demonstrates is not a TestBox bug:
    Copy code
    describe("Tests of testBox's toHaveKey", () => {
        it("is a control test", () => {
            st = {key="value"}
            expect(st).toHaveKey("key") // pass
        })
        it("handles a key with a null value", () => {
            st = {key=javacast("null", "")}
            expect(st).toHaveKey("key") // The key(s) [key] does not exist in the target object. Found keys are [[KEY]]
        })
        it("demonstrates the key does in fact exist", () => {
            st = {key=javacast("null", "")}
            expect(st.keyArray()).tobe(["key"]) // pass
        })
    })
    Same behaviour in CF and Lucee. (ping @lmajano)
  • t

    Tim

    05/23/2022, 7:54 PM
    this reminds me of this thread, where I was forced to eat my words.... https://cfml.slack.com/archives/C06TABBT8/p1650922356951229
  • t

    Tim

    05/23/2022, 7:56 PM
    StructKeyExists
    returns false if the value of the key is null.
  • t

    Tim

    05/23/2022, 7:58 PM
    I suppose that's probably the reason for the bug... whether TestBox should implement a different check for
    toHaveKey
    is worth a discussion, but I can see the argument for "`toHaveKey` should return the same thing as
    keyExists
    ."
  • a

    Adam Cameron

    05/23/2022, 8:03 PM
    Yeah, I was not sure, hence the Q. I can see arguments both ways. Was easy enough to work around, so I'm not so bothered I guess.
  • a

    Adam Cameron

    05/23/2022, 8:03 PM
    I kinda hoped TestBox wouldn't be as rubbish as CF & Lucee here. But at the same time it makes sense that it does mimic their behaviour.
  • l

    lmajano

    05/25/2022, 10:40 PM
    Yea, I see the issue
  • l

    lmajano

    05/25/2022, 10:40 PM
    I think we can improve on the lucee/adobe crap where the
    structKeyExists()
    is not returning
  • l

    lmajano

    05/25/2022, 10:40 PM
    we can use the
    keyArray()
    and test that
  • l

    lmajano

    05/25/2022, 10:41 PM
    instead of checking the existence in the struct
1234Latest