http://coldfusion.com logo
Docs
Join the conversationJoin Slack
Channels
adobe
advent-of-code
auwcl
aws
books
bot-dev
box-products
cfeclipse
cfkrauts
cflint
cfml-beginners
cfml-general
cfml-tuning
cfsummit2022
cfwheels
ci
community_courses
css
devops-general
docker
docker-commandbox
documentation
events
friday-puzzle
fusion-reactor
fw1
ide
java-and-jvm
javascript
jobs
jobs-non-us
linen-dev
lucee
masacms
meta
migrations
mura
music
nosql
object-oriented
orm
perf-monitor
prog-general
slack-help
sql
taffy
testing
version-control
vuejs
water-cooler
Powered by Linen
testing
  • r

    richard.herbert

    08/26/2022, 1:15 PM
    I'm not using the
    runner.cfm
    I want to use the
    test-browser
    that lets you move up and down your tests directory to find the actual test cfc you want to run and then it opens a new window just for that cfc which, for me, is showing an empty page
  • t

    Tim

    08/26/2022, 1:34 PM
    yeah. that's what I do to. And the cfc is the file in the URL, and if I run that page without
    method=runRemote
    then it runs my tests, and displays the test report.
  • r

    richard.herbert

    08/26/2022, 1:42 PM
    Hummm, I'm not sure how that would run? My understanding is that by having your tests extend
    testbox.system.BaseSpec
    it gets access to the
    runRemote
    method which you add to your url, that then handles the processing and presentation of the test results.
  • n

    Niek

    09/06/2022, 4:37 PM
    Hi, I am fairly new to TestBox and Coldbox, but I run into an issue which I don’t understand. I have written a BDD test which tests some Coldbox code. The Coldbox code makes use of a Service. Services need a reinit when you change some code, so every time I run my test, I need the Coldbox application to reinit. The strange thing is, when I run my test on the commandbox cli, a reinit takes place automatically since every change in my Service is visible immediately. However when I run the same test in the browser, a reinit does not take place. I have to do a reinit manually first and then I can run my test in the browser. The URL called from the commandbox CLI is: http://myhost/tests/runner.cfm?&labels=mytest&recurse=true&reporter=json&verbose=false The URL called from the browser is: http://myhost/tests/specs/integration/forms/StoreFormDataTest.cfc?method=runRemote Both run the exact same test, but the first one does a reinit and the second one does not. How can I get the test from the browser to initiate a reinit before running the test?
    a
    w
    4 replies · 3 participants
  • j

    Jim Priest

    09/08/2022, 5:05 PM
    Ohhhh cbPlaywright - this looks interesting 🙂
    d
    2 replies · 2 participants
  • j

    joechastain

    09/19/2022, 11:46 AM
    Good morning. Hope a good weekend was had by all. After a few false starts, I feel like I'm actually and finally building up some momentum with testing. Eric Peterson gave a great presentation on cbPlaywright for end-to-end testing at ITB, which was the match that lit the fuse. I've been spending as much time as I can working on various kinds of testing since then. I have a fairly decent handle on end-to-end tests with cbPlaywright (seriously, what a great tool), and I have a decent-ish (but growing) handle on unit tests and mocking with Testbox. So right now I am working on integration tests with Testbox. I'm trying to test a typical form submission and the associated results on a results page. To pass in all the form fields for my integration tests I'm doing something like
    getRequestContext().setValue( "employeeName", "Joseph Chastain" );
    before the
    execute
    call. I know I can get the rendered results page and check for various things with
    expect( event.getRenderedContent() ).toInclude(  "whatever" );
    But I'm hoping I can get specific values that are calculated in the handler. It looks like I can do this if I stored them in the PRC scope with
    event.getPrivateCollection()
    but I don't typically use the PRC scope. I pass the values to the results view via the
    args
    param in the
    event.setView()
    call in the handler. Is there a way to get the values in the args param in the test? Or do I need to start using the PRC scope if I want to do this? I checked the docs but, if there is anything, I didn't see it. Appreciate any insights on this. Thanks.
    s
    4 replies · 2 participants
  • j

    joechastain

    09/30/2022, 2:23 PM
    Happy Friday all. How does everyone handle their tests as far as version control is concerned? Same repo as the code or a separate repo? If the same, what's the best way to keep the tests out of production? The best I've come up with so far is adding something to our deployment script to just remove the tests directory in prod.
    j
    t
    +1
    9 replies · 4 participants
  • a

    aliaspooryorik

    10/03/2022, 11:41 AM
    Is there a testbox header that is the failures + errors count? Using AWS CodeBuild (which does a curl to the CFM runner) and have to check both currently. Or should I be looking at something else instead of the
    x-testbox-totalError
    and
    x-testbox-totalFail
    ?
    3 replies · 1 participant
  • a

    Adam Cameron

    10/05/2022, 10:27 PM
    Just in case yer interested in testing outside of CFML: https://blog.adamcameron.me/2022/10/data-driven-tests-in-junit-and-kotest.html
  • a

    Adam Cameron

    10/09/2022, 2:48 PM
    It's Kotlin rather than CFML, but the concepts and the techniques are the same, so I figured it's worth sharing: https://blog.adamcameron.me/2022/10/kotlin-tdd-writing-tests-for-small-web.html
    👍🏻 1
  • t

    Tim

    10/12/2022, 1:52 PM
    Is there a way to override the mockbox stub directory universally, via Application.cfc or something? I see that I can do it within an individual test via
    getMockBox()
    . But I don't see a single location that would affect all of my tests.
  • l

    lmajano

    10/12/2022, 8:16 PM
    hmm, good point
  • l

    lmajano

    10/12/2022, 8:16 PM
    I don’t think there is
  • l

    lmajano

    10/12/2022, 8:17 PM
    but we can do a setting somewhere
    t
    1 reply · 2 participants
  • l

    lmajano

    10/12/2022, 8:17 PM
    good point
  • l

    lmajano

    10/12/2022, 8:17 PM
    maybe when isntantiating testbox
  • j

    James Balaguer

    10/18/2022, 9:50 PM
    Using Testbox is ok to use
    expect()
    without using
    describe
    and
    it
    ? meaning just like an `assert()`:
    function testExpectationExamples () {
    		var message = "A custom message can be prepended to the error message!";
    
    		// toBe( expected, [message] ) : Assert something is equal to each other, no case is required
    		var value = "myValue";
    		expect(value).toBe("myvalue", message);
    		expect(value).toBe("myValue", message);
    		expect(value).toBe("MYVALUE", message);
    }
    a
    l
    11 replies · 3 participants
  • g

    gpickin

    10/19/2022, 9:30 PM
    Anyone using testbox, you might like something I've been working on, a shareable bunch of tools, allows me to do things like this. New matchers, new helpers, easy to add into testbox, but saves lots of code, lots more readable, way more readable messages when tests do not pass. @Adam Cameron might have given me an idea or two 😉
    var oResponse = deserializeJSON( event.getRenderedContent() );
    expect( oResponse ).toBeStruct()
        .toHaveKeyWithCase( "error" )
        .toHaveKeyWithCase( "messages" );
    expect( oResponse.error ).toBeFalse();                        
    expect( oResponse.messages )
        .toBeArray()
        .toHaveLengthGTE( 1 );
        expect( oResponse.messages[1] ).toBe( "postPandaDocWebhookRecipientCompletedADocument Interception point announced" );
    to
    expect( event ).toHaveAPISuccessWithMessage(    "postPandaDocWebhookRecipientCompletedADocument Interception point announced" );
  • a

    Adam Cameron

    10/20/2022, 9:54 AM
    Yeah implementing one's own bespoke matchers is something ppl should always consider if it can give a name to a commonly-used expectation. The second version there is much clearer as to what the expectation is.
  • a

    Adam Cameron

    10/20/2022, 9:54 AM
    (https://testbox.ortusbooks.com/in-depth/expectations/custom-matchers)
  • a

    Adam Cameron

    10/20/2022, 9:55 AM
    I have to admit it's not something I have done. And I ought to have.
    j
    2 replies · 2 participants
  • z

    zackster

    10/26/2022, 10:34 AM
    guess it's slightly OT, but which testing framework do people use for their javascript side of their cfml apps?
    j
    g
    +3
    8 replies · 6 participants
  • j

    joechastain

    10/26/2022, 11:34 AM
    I believe I found a bug in cbplaywright v1.0.2 for ACF (I'm using ACF 2021.0.05). When I use the
    route
    helper function, I get an error message that states
    Variable STRUCTVALUEARRAY is undefined
    in
    cbPlaywright\models\PlaywrightMixins.cfm
    on line 73. That line is
    var pathArray = structValueArray( arguments );
    —
    structValueArray
    is not a function in ACF.
    z
    m
    +3
    14 replies · 6 participants
  • j

    Jim Priest

    11/04/2022, 3:07 PM
    This looks like an interesting testing ide tool from JetBrains - seems like it's combining the browser, db and code ide all in one... https://www.jetbrains.com/aqua/
    👍 1
  • z

    zackster

    12/07/2022, 5:56 PM
    anyone know of a tool to compare junit test results, lucee's build outputs them, I'd like to be able to compare runs
    1 reply · 1 participant
  • s

    sknowlton

    12/09/2022, 12:44 PM
    qq for those of you using testbox in your ci/cd deployments and also using docker: do you use a non-finalized commandbox image so you can run commandbox with
    testbox run
    or do you launch your tests some other way?
    z
    1 reply · 2 participants
  • j

    joechastain

    01/27/2023, 6:34 PM
    I've been able to successfully write some integration and unit tests for an app that doesn't require authentication (hooray!). However, now I'm starting some tests on an app that does require authentication. Unit tests are still no problem, however, I'm struggling to figure out how to write an integration test when I need
    cgi.remote_user
    populated in
    main.index
    as I'm doing something like
    userId = cgi.remote_user
    and then passing
    userID
    into a function to retrieve data and then display it on the screen based on who is logged in. What is the best approach here?
    z
    b
    5 replies · 3 participants
  • j

    johnbarrett

    01/31/2023, 12:29 AM
    @johnbarrett has left the channel
  • j

    joechastain

    02/10/2023, 4:55 PM
    In Testbox, for integration testing, is it possible to mock objects that are called from a handler prior to the
    execute
    call of the handler?
    a
    17 replies · 2 participants
  • a

    Adam Cameron

    03/11/2023, 3:09 PM
    https://blog.adamcameron.me/2023/03/php-phpunit-tdd-unit-testing-abstract.html
Powered by Linen
Title
a

Adam Cameron

03/11/2023, 3:09 PM
https://blog.adamcameron.me/2023/03/php-phpunit-tdd-unit-testing-abstract.html
View count: 1