Loading ...
Sorry, an error occurred while loading the content.

Testing methods that implement factory pattern.

Expand Messages
  • Kamal Ahmed
    Hi, I need some help here. I am testing a class WmJournalLogger . method under test: public final void log(Level inLevel, String inKey, Object inParam) {
    Message 1 of 4 , Apr 3, 2006
    • 0 Attachment
      Hi,



      I need some help here.

      I am testing a class "WmJournalLogger".



      method under test:



      public final void log(Level inLevel, String inKey, Object inParam) {



      GlobalizedEvent event = _eventFactory.create(_bundleName, inKey,



      inParam, getComponentId(), getSubcomponentId());



      log(inLevel, event);



      }







      Now as far as I understand:

      When we instantiate WmJournalLogger, and then call the log method with the
      parameters declared above, a globalized event is created using

      GlobalizedEventFactory instance.

      Now since this is a Factory pattern, hence beased on the parameters passed
      to the log() method, namely log(Level inLevel, String inKey, Object
      inParam)

      The create method :



      = _eventFactory.create(_bundleName, inKey,



      inParam, getComponentId(), getSubcomponentId());



      is called, and generates the correct event.

      And following that , a log gets called with Level and event field.

      Now I am trying to figure out, how could I test this log method, Maybe:



      Create a new WmJournalLogger

      call (Level inLevel, String inKey, Object inParam)

      somehow verify that a new GlobalizedEvent is created

      log(inLevel, event); is called, which calls, log(Level inLevel,
      GlobalizedEvent inEvent), and eventually logger.log(inLevel, inEvent)





      Now, My test method: (and this is where I need your help)





      public void testlogLevelKeyParam() {



      subjectConsoleAppender = new ConsoleAppender();



      LoggerContext ctx = LoggerContext.getInstance();



      ProxyWmJournalLogger wml = new ProxyWmJournalLogger(ctx,
      _bundleName,



      COMPONENT_ID, SUB_COMPONENT_ID);







      subjectConsoleAppender.activateOptions();



      wml.log(Level.ERROR, LoggerContext.SOURCE_ID_PROP_KEY,
      MSG_PARAM_SET_A);



      wml.setLevel(Level.DEBUG);



      assertEquals(Level.DEBUG, wml.getLevel());







      }

      So I create a WmJournalLogger, then I need to call the appropriate log
      method:

      wml.log(Level.ERROR, LoggerContext.SOURCE_ID_PROP_KEY, MSG_PARAM_SET_A);



      now I need to verify:



      creation of a new GlobalizedEvent

      _logger.log(inLevel, inEvent);



      I am not sure how I would do this.

      Could you please give me some clue.



      Thanks,



      -Kamal.



      [Non-text portions of this message have been removed]
    • Andi Mirani
      Hi all, I have problems with Junit test lately. Before Junit 4.0 is launched, I was using Junit 3.8 to testing my java code and it runs well; However, now it s
      Message 2 of 4 , Apr 4, 2006
      • 0 Attachment
        Hi all,

        I have problems with Junit test lately. Before Junit 4.0 is launched, I was using Junit 3.8 to testing my java code and it runs well; However, now it's hard for me to test it even I'm using the same method.

        Is there any impact if I use old version Junit (Junit3.8) after the existing of Junit 4.0

        I checked the CLASSPATH, it's correct (in my thought)

        here the briefly description in below

        C:\junit\junit381>dir
        Volume in drive C has no label.
        Volume Serial Number is 88ED-E643
        Directory of C:\junit\junit381
        007/04/2005 07:21 AM 579 .classpath
        03/23/2006 02:48 PM <DIR> .metadata
        03/23/2006 02:48 PM <DIR> AliceMain
        03/23/2006 02:48 PM <DIR> Compiler
        03/23/2006 02:48 PM <DIR> CompTest
        03/23/2006 02:48 PM <DIR> Core
        02/19/2006 01:17 PM 15,172 cpl-v10.html
        02/19/2006 01:17 PM <DIR> doc
        03/23/2006 02:48 PM <DIR> Docs
        02/19/2006 01:17 PM <DIR> javadoc
        03/28/2006 04:23 PM <DIR> junit
        02/19/2006 01:45 PM 29 junit.bat
        02/19/2006 01:17 PM 121,070 junit.jar
        03/28/2006 07:16 PM 607,052 junit4.jar
        06/29/2005 09:01 PM 12,127 out.txt
        02/19/2006 01:17 PM 21,614 README.html
        02/19/2006 01:17 PM 57,635 src.jar

        10 File(s) 835,664 bytes
        15 Dir(s) 30,426,025,984 bytes free
        C:\junit\junit381>

        -------------------------------------------------------------------------------------------------------------------------
        sub CLASSPATH:
        Variable Name is JAVA_HOME
        Variable Value is C:\j2sdk1.4.2_10

        sub CLASSPATH:
        Variable Name is JUNIT_HOME
        Variable Value is C:\junit\junit381


        main CLASSPATH:
        Variable Name is CLASSPATH
        Variable Value is %JUNIT_HOME%\junit.jar;%JAVA_HOME%\lib\tools.jar

        Then I run for testing with using command:
        C:\junit\junit381> java junit.swingui.TestRunner

        Then the GUI Junit testing popup, but there's no more sample test that I could run it. It say:
        No Test Cases found
        Check that the configured 'TestCollector' is supported on this platform


        ===========================================================

        Thank you for your help guys


        ~Andi














        ---------------------------------





        ---------------------------------
        Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2¢/min or less.

        [Non-text portions of this message have been removed]
      • MNASRI Riadh
        Hello, Please I have to test (with junit of course) a swing application (developed eclipse plugin) that communicates with an msde database. I would like to
        Message 3 of 4 , Apr 6, 2006
        • 0 Attachment
          Hello,
          Please I have to test (with junit of course) a swing application (developed eclipse plugin) that communicates with an msde database.
          I would like to know if there are ways , practises or technics to do that.
          Thank you in advance
          Good luck for all
          Best regards
          Riadh MNASRI


          ---------------------------------
          Nouveau : téléphonez moins cher avec Yahoo! Messenger ! Découvez les tarifs exceptionnels pour appeler la France et l'international.Téléchargez la version beta.

          [Non-text portions of this message have been removed]
        • Kamal Ahmed
          Riadh, Here are some of the UI test to0ls, which are extensions of JUnit: Marathon Marathon is a gui-test tool that allows you to play and record scripts
          Message 4 of 4 , Apr 6, 2006
          • 0 Attachment
            Riadh,



            Here are some of the UI test to0ls, which are extensions of JUnit:



            Marathon



            Marathon is a gui-test tool that allows you to play and record scripts
            against a java swing ui. It's written in java, and uses python as its
            scripting language - the emphasis being on an extremely simple, readable
            syntax that customers/testers/analysts feel comfortable with. It is full
            fledged python, so it is also extremely powerful and customizable for
            developer-types.

            Thought Works, February 08, 2003



            Jacareto



            Jacareto is a capture&replay framework for Java applications and applets. It
            allows you to easily create your own capture&replay tools. Jacareto is very
            flexible; you can write your own capture modules, replay modules, classes
            which handle special components, editors, record types, record elements and
            tests. You can also group record elements together to build high-level
            structures (qualitative analysis). By extracting data sets from records,
            quantitative analyses can be performed

            Christian Spannagel, February 08, 2003



            Abbot



            Abbot is a scripted Java GUI testing framework that supports recording and
            playback of semantic user events, as well as component state evaluation for
            both unit and functional testing.

            Timothy Wall, May 20, 2002



            Pounder



            Pounder allows you to record scripts using your Java GUI components and then
            play them back in JUnit or alone in Pounder. It is licensed under the GNU
            Library General Public License.

            Matthew Pekar, May 09, 2002



            Jemmy Module



            Jemmy is a Java library that is used to create automated tests for Java GUI
            applications. It contains methods to reproduce all user actions which can
            performed on swing components (i.e. button pushing, text typing, tree node
            expanding, ...). JemmyTest is a program written in Java which uses the Jemmy
            API to test applications. Jemmy is a NetBeans independent module, you can
            use it separately as well as together with the NetBeans IDE.

            NetBeans, February 20, 2002



            JFCUnit



            An extension to the JUnit framework that enables you to execute unit tests
            against code that presents a Swing based interface.

            July 04, 2001



            Hope this helps,

            -Kamal.





            _____

            From: junit@yahoogroups.com [mailto:junit@yahoogroups.com] On Behalf Of
            MNASRI Riadh
            Sent: Thursday, April 06, 2006 5:21 AM
            To: junit@yahoogroups.com
            Subject: [junit] How to test a Swing application



            Hello,
            Please I have to test (with junit of course) a swing application
            (developed eclipse plugin) that communicates with an msde database.
            I would like to know if there are ways , practises or technics to do that.
            Thank you in advance
            Good luck for all
            Best regards
            Riadh MNASRI


            ---------------------------------
            Nouveau : téléphonez moins cher avec Yahoo! Messenger ! Découvez les tarifs
            exceptionnels pour appeler la France et l'international.Téléchargez la
            version beta.

            [Non-text portions of this message have been removed]







            SPONSORED LINKS


            Basic programming language

            C programming language

            Computer programming languages


            The c programming language

            C++ programming language

            List of programming languages



            _____

            YAHOO! GROUPS LINKS



            * Visit your group "junit <http://groups.yahoo.com/group/junit> " on
            the web.

            * To unsubscribe from this group, send an email to:
            junit-unsubscribe@yahoogroups.com
            <mailto:junit-unsubscribe@yahoogroups.com?subject=Unsubscribe>

            * Your use of Yahoo! Groups is subject to the Yahoo!
            <http://docs.yahoo.com/info/terms/> Terms of Service.



            _____



            [Non-text portions of this message have been removed]
          Your message has been successfully submitted and would be delivered to recipients shortly.