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

Re: Use of Assert

Expand Messages
  • lescoutinhovr
    Hi! Would not work if you add the -ea argument to the VM in Eclipse?
    Message 1 of 4 , Jan 7, 2010
    • 0 Attachment
      Hi!

      Would not work if you add the -ea argument to the VM in Eclipse?

      --- In pcgen_developers@yahoogroups.com, James Dempsey <jdempsey@...> wrote:
      >
      > Hi,
      >
      > I am currently debugging some unit tests which are failing under maven 2
      > (in the CI build) but not when run in Eclipse or ant.
      >
      > It turns out that the Java assert command used in the unit test is not
      > stopping processing when it gets a false result if running in Eclipse
      > but it is when running under Maven 2. This is because "By default,
      > assertions are disabled at runtime"
      > http://java.sun.com/j2se/1.4.2/docs/guide/lang/assert.html#enable-disable
      >
      > So the assert statements really aren't doing what is expected.
      >
      > As a result I've changing the use of assert to assertTrue for the unit
      > tests. The other advantage here is that we can attach a description to
      > the failure to assist in debugging. See
      > http://pcgen.svn.sourceforge.net/pcgen/?rev=11274&view=rev for what I
      > have updated.
      >
      > From what I can see the 3 test classes updated in plugin.lsttokens.add
      > should be failing as they are flagging an invalid condition. Tom, could
      > you advise if this is a problem in the code or if the tests need to be
      > updated please?
      >
      > Cheers,
      > James Dempsey
      > PCGen Code SB
      >
    • James Dempsey
      Hi, Yes that would work, but you d need to add that to the run config each time you ran the tests though. That does really adhere to the principle of least
      Message 2 of 4 , Jan 7, 2010
      • 0 Attachment
        Hi,

        Yes that would work, but you'd need to add that to the run config each
        time you ran the tests though. That does really adhere to the "principle
        of least surprise". I think what was intended was assertTrue, but when
        looking at that it was breaking negative tests (testing of invalid
        conditions) anyway so I just commented those occurrences out.

        Cheers,
        James.

        On 8/01/2010 12:19 PM lescoutinhovr wrote
        > Hi!
        >
        > Would not work if you add the -ea argument to the VM in Eclipse?
        >
        > --- In pcgen_developers@yahoogroups.com, James Dempsey <jdempsey@...> wrote:
        >
        >> Hi,
        >>
        >> I am currently debugging some unit tests which are failing under maven 2
        >> (in the CI build) but not when run in Eclipse or ant.
        >>
        >> It turns out that the Java assert command used in the unit test is not
        >> stopping processing when it gets a false result if running in Eclipse
        >> but it is when running under Maven 2. This is because "By default,
        >> assertions are disabled at runtime"
        >> http://java.sun.com/j2se/1.4.2/docs/guide/lang/assert.html#enable-disable
        >>
        >> So the assert statements really aren't doing what is expected.
        >>
        >> As a result I've changing the use of assert to assertTrue for the unit
        >> tests. The other advantage here is that we can attach a description to
        >> the failure to assist in debugging. See
        >> http://pcgen.svn.sourceforge.net/pcgen/?rev=11274&view=rev for what I
        >> have updated.
        >>
        >> From what I can see the 3 test classes updated in plugin.lsttokens.add
        >> should be failing as they are flagging an invalid condition. Tom, could
        >> you advise if this is a problem in the code or if the tests need to be
        >> updated please?
        >>
        >> Cheers,
        >> James Dempsey
        >> PCGen Code SB
      • thpr
        Hmm. Updated and looked at what is happening. It s a matter of using the method in two ways - one for valid, one for invalid. Leave the TODOs there and I ll
        Message 3 of 4 , Jan 8, 2010
        • 0 Attachment
          Hmm. Updated and looked at what is happening. It's a matter of using the method in two ways - one for valid, one for invalid. Leave the TODOs there and I'll look into the best way to test the grouping state.

          TP.

          --- In pcgen_developers@yahoogroups.com, James Dempsey <jdempsey@...> wrote:
          > From what I can see the 3 test classes updated in plugin.lsttokens.add
          > should be failing as they are flagging an invalid condition. Tom, could
          > you advise if this is a problem in the code or if the tests need to be
          > updated please?
        Your message has been successfully submitted and would be delivered to recipients shortly.