6 Replies Latest reply on Dec 1, 2008 10:19 PM by ssilvert

    Parrallel JSFUnit tests, is it possible?

    kragoth

      Well, as the title says... is it possible to have multiple JSFUnit tests running at the same time in different threads?

      Basically my problem is that our project is starting to get some rather large JSFUnit tests, and these tests are quite slow.
      So, what I was hoping to do, is farm off a few threads and run them in parrallel so that we can shorten our build time.

      So, has anyone attempted this or knows how this could be approached?
      Are there any JSFUnit limitations that could make this basically impossible?
      Or, does anyone have some good tips to make the JSFUnit tests run faster.

      Because at the moment I have around 13 tests and this can take around 5 - 7 mins, and this time is not going to get any shorter, with most of our tests still getting larger and new tests being written.

      Any ideas or pointers would be greatly appreciated.

      Thanks,
      Tim

        • 1. Re: Parrallel JSFUnit tests, is it possible?
          ssilvert

          Multiple threads should be OK as long as they don't share the same JSFSession instance. I haven't tested this out, but I can't think of any reason why it wouldn't work.

          I have around 200 tests and it runs in about two minutes. This includes starting/stopping Jetty several times. Jetty is the default for Maven, but I am actually set up to run my tests against different versions of Tomcat and JBoss as well. In my experience, starting and stopping the server is usually the slowest part and servers vary widely in that regard.

          That being said, JSFUnit is in desperate need of profiling. I really have no idea where the bottlenecks are and it is obviously something I should know with more authority. So if you do any profiling yourself, please share the results.

          Of course this goes without saying, but you will also want to look into optimizations for JSF and for your application as well.

          Stan

          • 2. Re: Parrallel JSFUnit tests, is it possible?
            ssilvert

            My earlier comment on multiple threads was misleading. The threads must be kicking off different tests, and I assume that what you are talking about is that each thread will tell JUnit to run different test classes.

            You can not kick off multiple threads from inside a test class. If you do that then you will run into the problem I describe here:
            http://www.jboss.org/community/docs/DOC-10971

            Stan

            • 3. Re: Parrallel JSFUnit tests, is it possible?
              kragoth

              I already understand the issue around sharing the same HttpSession with all JSFSessions as I had to work around this for a particular test where I needed a seperate user to login during my test. (Although, it would be really really nice if this restriction was removed :P, because then a whole bunch of my testing would be easier and more robust :) )

              So yes, if I was to implement this then I would have each thread run a test. Not try to create multiple threads in my test class.

              I'm not sure I'm going to get time to do this but, it's on my list of things that would be nice to do :)

              Now, you are doing 200 tests in 2 mins (WOW! :P).... are any of these tests actual multi-page, submission and application logic tests?
              Or are they just testing gui stuff? I still have to profile this, but it seems that most time is wasted in page transitions. So everytime I have a test that goes from one page to another with a bunch of application logic and a redirect at the end, my test time blows out.

              I havn't done much(any :P) work really with profilers so, that's something else I'll need to go learn. I've heard that there is a profile for eclipse that's not too bad so I'll go do some googling.

              On a side note.... for some reason I can't use the enter button while typing posts here anymore. Is anyone else having this problem? I'm having to type my replies in notepad and copy them across so I can insert blank lines. Weirdness!

              • 4. Re: Parrallel JSFUnit tests, is it possible?
                ssilvert

                These tests typically span only one or two pages and the applications themselves are very fast. They do more testing of server side state than testing the GUI.

                So if you don't notice that the application itself is slow, I'm wondering if it has something to with the combination of your pages and HtmlUnit. That is, maybe a regular browser loads your pages quickly but HtmlUnit loads them more slowly. You could measure page load time with a RequestListener:
                http://www.jboss.org/community/docs/DOC-12845

                Stan

                • 5. Re: Parrallel JSFUnit tests, is it possible?
                  kragoth

                  Ok, I'll have a look at that and see if I find anything out.

                  Thanks for the suggestion.


                  Oh, btw... my enter key is working again... seems as if firefox was just out on holidays :P

                  • 6. Re: Parrallel JSFUnit tests, is it possible?
                    ssilvert

                    I don't have any problem using the enter button. I'm using FireFox 3.0.4.

                    enter
                    enter
                    enter

                    Stan