Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    SmartGWT Unit Testing Framework

    Okay so I've been doing research on this topic for about a week now.

    Based on everything I've read and tried to do unit testing properly we basically have create a unit testing framework in GWT, something akin to JUnit. Then we use Selenium to do the basic check to see if the test was passed or not.

    Something similar to what you have in the showcase when the autotest flag is set:
    http://www.smartclient.com/smartgwt/...tured_category

    Other options include:
    Mocking 'broken' SGWT classes in GWTTestCase
    Put extensive work to 'push' methods up to a point where they are visible to Selenium

    So the question is, is there another option? Creating a JUnit like testing framework in SGWT is viable but non-trivial, do you have any suggestions on how to create such a framework? It seems like Isomorphic already has a relatively robust testing framework.

    Also what is this 'runStyle' option in GWT? I tried it out in Eclipse but it didn't seem to do anything, could you explain in a little more detail?

    Thanks!

    Related post:
    Originally posted by Isomorphic View Post
    We don't have a specific recommendation as we use something proprietary. However for non-unit tests that simulate user actions, we do recommend Selenium and have special support for it (see the Automated Testing overview in the SmartClient Reference).
    Originally posted by Isomorphic View Post
    This may suggest that GwtTestCase, which uses a fake HTMLUnit browser, cannot be used to run tests involving XML manipulation since it isn't a real browser.

    There is a notion of runStyle which might be used to force the test to run in a real browser.

    However, because of issues like the above we recommend focusing on Selenium testing rather than GwtTestCase.
    Related Docs:
    http://www.smartclient.com/smartgwte...edTesting.html
    Last edited by ksuen; 8 Aug 2014, 13:30.

    #2
    We do roughly this:

    Put extensive work to 'push' methods up to a point where they are visible to Selenium
    You may have seen that we already doc how to run a JUnit test that uses a real browser via Selenium.

    Our approach to maintaining a suite of SGWT Unit tests is basically an elaboration of this; we have a simple library that a unit test can use to report results that Selenium can detect, via rendering widgets with certain known IDs and contents.

    This is then connected to our TestRunner system so that we can store and compare results of test runs and send out notifications of regressions and fixes. At any given time we have 10-50 cloud machines spun up running the test suites (because they are enormous).

    If you'd like to be set up similarly, we can help you do this through some mixture of Feature Sponsorship and Consulting.

    Comment


      #3
      Thanks for responding, it's good to know that I'm sort of heading in the right direction.

      I was hoping on giving a developer more information as a test proceeds so my current approach is to basically duplicate some of the core functionality of JUnit, namely the assertion system.

      Do you have suggestions regarding my approach, any glaring issues I should be aware of?

      I'm aware of TestRunner the other doc linked in your post, we're not there yet :).

      PS: about consulting, unfortunately this is out of my hands, but I will definitely push for Isomorphic to get more directly involved in our project.
      Last edited by ksuen; 11 Aug 2014, 10:26.

      Comment


        #4
        No glaring issues, but there is a very long list of different kinds of very useful enhancements you might add.

        Replicating JUnit's assert() methods is one example and is something we did as well.

        Some of the things we do, which we would recommend also doing, include:

        1. automatically capture and store parts of the environment on failure (client logs, server logs, last RPCs, that kind of thing)

        2. auto-discovery of unit tests, so you just drop a .java file into the filesystem and it is automatically picked up and run as part of the TestRunner suite from then on - no registration step or separate creation of a Selenium script

        3. put in a mechanism to handle hung tests without hanging the whole suite

        4. add utilities to log / capture the current state of the application in various ways - pending RPCs, current component tree, etc

        .. too many other things to list ..

        We fully understand consulting being out of your control :) Be sure the powers-that-be understand that you might be doing a lot of wheel-reinventing if there's no coordination with Isomorphic in this instance.

        Comment


          #5
          Really appreciate the rapid response.

          Originally posted by Isomorphic View Post
          We fully understand consulting being out of your control :) Be sure the powers-that-be understand that you might be doing a lot of wheel-reinventing if there's no coordination with Isomorphic in this instance.
          Yeah I'm very aware that we might be doing wheel-reinventing, but...sigh... I would settle for priority forum support at this point, anyways...

          Thanks for the list, 2 and 3 definitely seem like good ideas. Though 1 and 4 go more into the huge area of logging O.o, which I'll probably ask about in a future forum post :D.

          Comment

          Working...
          X