Hamcrest Matchers

29 views
Skip to first unread message

tr...@neukomm.ca

unread,
Jan 7, 2014, 4:39:02 PM1/7/14
to jac...@googlegroups.com
Good day,

We are using Hamcrest Matchers in our JUnit tests and this does not seem to affect the coverage report.

Are they supported in any fashion?

Thank you,

Troy

Marc R. Hoffmann

unread,
Jan 8, 2014, 12:31:30 AM1/8/14
to jac...@googlegroups.com
Hi,

you can use Hamcrest Matchers with JaCoCo/EclEmma. There are no known
limitations.

Best regards,
-marc

tr...@neukomm.ca

unread,
Jan 8, 2014, 8:31:15 AM1/8/14
to jac...@googlegroups.com

Thanks for the reply,

The unfortunate thing is none of the objects tested with Matchers register as covered assertThat(result, hasProperty("x", equalTo("xValue")),

whereas making an assertion does assertEquals("xValue", result.getX()) does.


Henrik Horneber

unread,
Jan 8, 2014, 8:35:50 AM1/8/14
to jac...@googlegroups.com
What about assertThat(result.getX(), is(equalTo("xValue"))? Does that work?
Maybe it's just the hasProperty Matcher.






--
You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
"I find many of the machines of violence very attractive. Tanks, airplanes, warships, especially aircraft carriers."
- 14th Dalai Lama

Canadian Bacon

unread,
Jan 8, 2014, 10:51:42 AM1/8/14
to jac...@googlegroups.com
Good day, 

Tried that and it didn't work. I appreciate the help, there must be something simple wrong here but I have to move on for now. I will update this thread (or continue it) later.

Thanks for your interest,

Troy


--
You received this message because you are subscribed to a topic in the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jacoco/EN2N-XYGk2s/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jacoco+un...@googlegroups.com.

Andreas Sewe

unread,
Jan 8, 2014, 11:35:30 AM1/8/14
to jac...@googlegroups.com
Hi,

> The unfortunate thing is none of the objects tested with Matchers register as covered assertThat(result, hasProperty("x", equalTo("xValue")),
>
> whereas making an assertion does assertEquals("xValue", result.getX()) does.

hm, maybe Jacoco gets confused because some basic Hamcrest matchers are
contained not only in the Hamcrest JAR but are also part of the JUnit
JAR, i.e., they are on the classpath twice.

Can you check that this also occurs with matchers not part of your JUnit
JAR?

Hope this helps.

Andreas

--
Codetrails UG (haftungsbeschr�nkt)
The knowledge transfer company

Robert-Bosch-Str. 7, 64293 Darmstadt
Mobile: +49-170-811-3791
http://www.codetrails.com/

Managing Director: Dr. Marcel Bruch
Handelsregister: Darmstadt HRB 91940

Marc Hoffmann

unread,
Jan 8, 2014, 3:00:17 PM1/8/14
to jac...@googlegroups.com
Troy, can you please provide a small reproducer and shortly describe
what the expected result is?

Thanks,
-marc
>>> [1].
>>
>> --
>> "I find many of the machines of violence very attractive. Tanks,
>> airplanes, warships, especially aircraft carriers."
>> - 14th Dalai Lama
>>
>> --
>> You received this message because you are subscribed to a topic in
>> the Google Groups "JaCoCo and EclEmma Users" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/jacoco/EN2N-XYGk2s/unsubscribe
>> [2].
>> To unsubscribe from this group and all its topics, send an email to
>> jacoco+un...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out
>> [1].
>
> --
> You received this message because you are subscribed to the Google
> Groups "JaCoCo and EclEmma Users" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to jacoco+un...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out [1].
>
>
> Links:
> ------
> [1] https://groups.google.com/groups/opt_out
> [2] https://groups.google.com/d/topic/jacoco/EN2N-XYGk2s/unsubscribe

Canadian Bacon

unread,
Jan 8, 2014, 4:00:32 PM1/8/14
to jac...@googlegroups.com
I will throw up a sample possibly tomorrow when I can get back on that task, Thanks a bunch.


[1].

--
"I find many of the machines of violence very attractive. Tanks,
airplanes, warships, especially aircraft carriers."
- 14th Dalai Lama

--
You received this message because you are subscribed to a topic in
the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/jacoco/EN2N-XYGk2s/unsubscribe
[2].

To unsubscribe from this group and all its topics, send an email to
[1].

 --
 You received this message because you are subscribed to the Google
Groups "JaCoCo and EclEmma Users" group.
 To unsubscribe from this group and stop receiving emails from it,
--
You received this message because you are subscribed to a topic in the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jacoco/EN2N-XYGk2s/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jacoco+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages