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

    Adam Cameron

    07/18/2022, 10:03 PM
    That's the sort of thing I was thinking of. An interface, not an implementation
  • a

    Adam Cameron

    07/18/2022, 10:03 PM
    But TBH TestBox is yours, you have a DI implementation with WB, and this is gonna address most ppl's concerns.
  • w

    wil-shiftinsert

    07/19/2022, 8:15 AM
    Not really a coding thing, but I would love to see some better getting started guides. IMHO there should be some better examples for integration tests, some better examples to mock sessions, cookies and flash scopes. And some commandbox commands which are generating useful stuff instead of the incorrect templates the coldbox create integration-test and model-test are generating now. As a beginner ATM you are better of creating tests yourself instead of the commandbox generated code. From my own experience with some coworkers: It is not so easy for beginners to start with testbox. So how are others starting using it? Some newbie guide?
  • l

    lmajano

    07/20/2022, 3:13 PM
    I get you @wil-shiftinsert and there are many things we can improve. However, testing is as good as your code is. There is no magic pill where we can document integration testing for everybody, because that means they would have to code their app like we do. This is the tricky part about showcasing tons of examples of integration tests because it all depends on the code you write. Ultimately, tests are a reflection of your code.
    ✅ 1
  • l

    lmajano

    07/20/2022, 3:13 PM
    And there is no single reflection
  • l

    lmajano

    07/20/2022, 3:13 PM
    but I get it
  • w

    wil-shiftinsert

    07/20/2022, 3:29 PM
    That’s why some sample Code with some sample tests would be useful. But at least we could start by not generating incorrect code from commandbox. But as said, it is better to write our own code, so we understand what we are doing. I know there is no golden rule for integration tests, and for api’s some basic integration testing is not so hard at all. But as soon as we have dependencies in handlers on sessions or flash (typically not in API’s) I can hardly find any documentation. Actually I kicked out some flash parts from some handlers because there are other ways to do it and I didn’t want to waste my time anymore on it. The best way to learn atm is still following some workshop or viewing some video from people who have a lot more experience. Just missing some written documentation. I guess I am way too impatient to view all these videos and they are not searchable for keywords either 🙂 But don’t get me wrong, still love most box products.
    l
    • 2
    • 9
  • a

    Adam Cameron

    07/20/2022, 3:30 PM
    Also there is no shortage of material out there regarding writing jasmine-esque tests, how to write integration tests, the difference between unit, functional, acceptance, etc tests. This stuff is not specific to TestBox
    l
    • 2
    • 4
  • a

    Adam Cameron

    07/20/2022, 3:30 PM
    However maybe "better examples to mock sessions, cookies and flash scopes." is CFML-specific, so unless someone using MockBox writes them, they ain't gonna get written.
  • s

    seancorfield

    07/21/2022, 7:53 PM
    I'd also add: if you write your code so that either the scopes are passed in or at least you pass in CFCs that wrap the scopes (e.g., using IoC/DI), then you can just mock scopes using structs you pass in or set up your own mock CFCs. That's a much better approach, IMO.
  • s

    seancorfield

    07/21/2022, 7:55 PM
    And if your controller/handler CFCs are very minimal and all your business logic is in your model CFCs and those are completely independent of the framework/environment, then you're also in a better place. If you're having to mock a lot of your "environment", then your code is "poorly written", i.e., harder to test -- so the place to start is refactoring it to make it easier to test, rather than trying to mock out scopes etc.
  • a

    Adam Cameron

    07/21/2022, 8:46 PM
    All true, but often our code was written for us, by someone else who didn't give a shit about any of that. And as a result the code is an unmanageable, untestable pile of shite. Yet here we are needing to support it and test it because we are more professional than our predecessors.
  • a

    Adam Cameron

    07/21/2022, 8:49 PM
    I have a mountain of code that has inline request, session and application scope usage; and inline calls to external systems (<cfquery>, <cfftp> etc). And testing it is a bitch, even for me who likes to think I know a thing or two about testing strategies.
  • a

    Adam Cameron

    07/21/2022, 8:51 PM
    Too much testing guidance is framed with "first: let's assume all the code is impeccable", which is seldom where the person seeking help is starting from.
    👍 1
  • t

    timothyfarrar

    08/02/2022, 7:51 PM
    Anyone here have any experience with test data management tools? What have you used, liked, hated, etc.
    j
    • 2
    • 7
  • d

    danmurphy

    08/11/2022, 8:58 PM
    We have a
    BaseIntegrationTest
    that most of our integrations tests extend so we don’t have to do the same setup for each one. We have an aroundEach in that
    BaseIntegrationTest
    which wraps each test in a transaction so we can rollback any database changes that each test did to prep for data for the test. That works great if the database transactions are in the actual
    it()
    test. But if we do a database action in the
    beforeEach()
    it is not rolling back the transaction and is committing instead. Any ideas on how to change this so the rollback works whether the database action occurs in the
    it()
    or the
    beforeEach()
    ? (function in the thread)
    t
    e
    w
    • 4
    • 8
  • d

    danmurphy

    08/12/2022, 2:36 AM
    I’m using ColdBox v6 and Testbox v4. I have a handler that I’m doing some integration tests with. But I want to break out a bit into a private method on the handler. Maybe that should go in a Service instead, but it seems like overkill for this little private method. So how do I test that private method? I really just want to unit test that method on the handler (I think).
    a
    a
    • 3
    • 14
  • r

    richard.herbert

    08/15/2022, 1:54 PM
    Can I mock the
    cgi
    scope?
    a
    a
    j
    • 4
    • 17
  • r

    richard.herbert

    08/26/2022, 8:50 AM
    What have I got wrong here? I'm trying to add Testbox and testing to an old app and
    <http://example.com/testbox/tests/runner.cfm|example.com/testbox/tests/runner.cfm>
    runs and displays all the tests as expected and
    <http://example.com/testbox/test-browser/|example.com/testbox/test-browser/>
    shows the listing of
    /testbox/tests/specs/
    which is all good. But when I click into any of the actual test components, like
    <http://example.com/testbox/tests/specs/BaseTest.cfc?method=runRemote|example.com/testbox/tests/specs/BaseTest.cfc?method=runRemote>
    I get an empty screen and no HTML. What could I got wrong?
    a
    • 2
    • 3
  • t

    Tim

    08/26/2022, 12:56 PM
    Mine started doing this recently. If you remove the method=runRemote, it'll run corrctly
  • t

    Tim

    08/26/2022, 12:57 PM
    I haven't gotten a chance to figure out what's broken and file a bug yet though
  • r

    richard.herbert

    08/26/2022, 1:06 PM
    But surely just calling
    <http://example.com/testbox/tests/specs/BaseTest.cfc|example.com/testbox/tests/specs/BaseTest.cfc>
    just tries to invoke the cfc which will fail?
  • t

    Tim

    08/26/2022, 1:07 PM
    oh, sorry. i didn't notice that part.... my links are all to the individual test cfcs
  • t

    Tim

    08/26/2022, 1:10 PM
    but yeah, it's the actual cfc's. the runner seems to sort it out.
  • 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?&amp;labels=mytest&amp;recurse=true&amp;reporter=json&amp;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
    • 3
    • 4
  • j

    Jim Priest

    09/08/2022, 5:05 PM
    Ohhhh cbPlaywright - this looks interesting 🙂
    d
    • 2
    • 2
  • 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
    • 2
    • 4
1234Latest