harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nathan Beyer <nbe...@gmail.com>
Subject Re: Hamcrest
Date Mon, 10 Aug 2009 01:25:50 GMT
On Fri, Aug 7, 2009 at 4:22 PM, Mark Hindess<mark.hindess@googlemail.com> wrote:
>
> In message <3b3f27c60908062111s37c1f766j61af21b97740febc@mail.gmail.com>,
> Nathan Beyer writes:
>>
>> I updated JUnit to 4.6 and add Hamcrest Library 1.1 (the extra
>> matchers). Everyone will need to do a fetch to get the latest
>> dependencies.
>
> I like this change but had we agreed on this already?  I thought the
> discussion was ongoing.

Perhaps. It seems like we've had this conversation a dozen times and
it has always died with "but if we just moved to TestNG life would be
great".

The upgrade to JUnit was something that needed to be done anyway. I
just added the extra library util to push things over the edge. We can
pull that out if no one uses it.


>
>> I didn't add the hamcrest library to all of the unit test compiles or
>> runs. Those can be added as they are needed.
>
> You broke a fresh checkout and build.  You renamed junit.jar
> to junit-4.6.jar which is a good idea except that all of the
> -Xbootclasspath/a settings for tests still expect it to be called
> junit.jar.  (Tidying up the cleaning of hdk test artifacts is on my
> todo list - which will help catch this kind of problem without a fresh
> checkout.)
>
> I've fixed it by making the copy to the hdk rename the file to junit.jar
> in r802196.  This isn't ideal but I'm still working on this area too.
>

I did a clean build, including completely deleting all depends
folders, on Windows x86. I thought everything was referencing the
'${junit.jar}' property, at least that's all I could find with the
various searches I attempted.

Sorry about that. Thanks for cleaning up my mess.

> Regards,
>  Mark.
>
>> On Thu, Aug 6, 2009 at 7:24 PM, Nathan Beyer<ndbeyer@apache.org> wrote:
>> > To fully utilize Hamcrest, we just need to bring in the hamcrest lib
>> > dependency to get some of the more useful Matchers or we need to move
>> > to the 'junit-deps' JAR, which includes those Matchers.
>> >
>> > I love the Matchers and using JUnit 4 tests, however, as I recall, one
>> > of the things holding me back from changing tests was that to properly
>> > run JUnit 4 and JUnit 3 tests was that build be run with Ant 1.7+.
>> > That's no longer a concern anymore, so I say it's time to just start
>> > doing it.
>> >
>> > JUnit 4.6 was released recently, so we probably need to upgrade to that a=
>> s well.
>> >
>> > -Nathan
>> >
>> > On Thu, Aug 6, 2009 at 3:17 AM, Charles Lee<littlee1032@gmail.com> wrote:
>> >> Great News. I have checked the RELEASE NOTES about junit4.4. It seems ha=
>> s
>> >> already include this hamcrest.
>> >> Here is what it said:
>> >>
>> >> Advantages of this assertion syntax include:
>> >>
>> >> =C2=A0 -
>> >>
>> >> =C2=A0 More readable and typeable: this syntax allows you to think in te=
>> rms of
>> >> =C2=A0 subject, verb, object (assert "x is 3") rather than assertEquals,=
>>  which
>> >> =C2=A0 uses verb, object, subject (assert "equals 3 x")
>> >> =C2=A0 -
>> >>
>> >> =C2=A0 Combinations: any matcher statement s can be negated (not(s)), co=
>> mbined (
>> >> =C2=A0 either(s).or(t)), mapped to a collection (each(s)), or used in cu=
>> stom
>> >> =C2=A0 combinations (afterFiveSeconds(s))
>> >> =C2=A0 -
>> >>
>> >> =C2=A0 Readable failure messages. Compare
>> >>
>> >> =C2=A0 assertTrue(responseString.contains("color") ||
>> >> responseString.contains("colour"));
>> >> =C2=A0 // =3D=3D> failure message:
>> >> =C2=A0 // java.lang.AssertionError:
>> >>
>> >>
>> >> =C2=A0 assertThat(responseString, anyOf(containsString("color"),
>> >> containsString("colour")));
>> >> =C2=A0 // =3D=3D> failure message:
>> >> =C2=A0 // java.lang.AssertionError:
>> >> =C2=A0 // Expected: (a string containing "color" or a string containing
=
>> "colour")
>> >> =C2=A0 // =C2=A0 =C2=A0 =C2=A0got: "Please choose a font"
>> >>
>> >> =C2=A0 -
>> >>
>> >> =C2=A0 Custom Matchers. By implementing the Matcher interface yourself,
=
>> you can
>> >> =C2=A0 get all of the above benefits for your own custom assertions.
>> >> =C2=A0 -
>> >>
>> >> =C2=A0 For a more thorough description of these points, see Joe Walnes's
>> >> =C2=A0 original post <http://joe.truemesh.com/blog/000511.html>.
>> >>
>> >> Have fun and enjoy it :-)
>> >>
>> >>
>> >> On Thu, Aug 6, 2009 at 4:05 PM, Jimmy,Jing Lv <firepure@gmail.com>
wrote=
>> :
>> >>
>> >>> Sounds interesting Charles.
>> >>>
>> >>> I guess it should require more dependence on Hamcrest, which may be
som=
>> e
>> >>> extra cost for building and footprint? So would you please describe
wha=
>> t
>> >>> the
>> >>> advantages are, and share your experience? Or share us some examples?
>> >>>
>> >>> 2009/8/6 Charles Lee <littlee1032@gmail.com>
>> >>>
>> >>> > Hi guys,
>> >>> >
>> >>> > These days I am writing some testcase to the harmony using Hamcrest.
=
>> I'd
>> >>> > like to introduce harmcrest to the community :-)
>> >>> >
>> >>> > Hamcrest provides a library of matcher objects (also known as constra=
>> ints
>> >>> > or
>> >>> > predicates) allowing 'match' rules to be defined declaratively,
to be
>> >>> used
>> >>> > in other frameworks. It maybe the only third-party plugin which
junit
>> >>> > supports. Check out these beautiful asserts:
>> >>> > 1. assertThat(object1, equalTo(object2))
>> >>> > 2. assertThat(object1, is(anything()))
>> >>> > 3. assertThat(boolean, allOf(boolean1, boolean2)) =C2=A0 (like
and)
>> >>> > 4. assertThat(boolean, anyOf(boolean1, boolean2)) (like or)
>> >>> > 5. assertThat(obj1, instanceOf(CLASS))
>> >>> > 6. assertThat(obj1, compatibleTo(CLASS))
>> >>> > .............
>> >>> >
>> >>> > Hamcrest makes unit tests more readable. Besides it speed my unit
cod=
>> ing
>> >>> > :-)
>> >>> >
>> >>> > More detail, please visit Hamcrest <http://code.google.com/p/hamcrest=
>> />.
>> >>> >
>> >>> > --
>> >>> > Yours sincerely,
>> >>> > Charles Lee
>> >>> >
>> >>>
>> >>>
>> >>>
>> >>> --
>> >>>
>> >>> Best Regards!
>> >>>
>> >>> Jimmy, Jing Lv
>> >>> China Software Development Lab, IBM
>> >>>
>> >>
>> >>
>> >>
>> >> --
>> >> Yours sincerely,
>> >> Charles Lee
>> >>
>> >
>>
>
>
>

Mime
View raw message