hamcrest « junit « Java Testing Q&A

Home
Java Testing Q&A
1.Development
2.FindBugs
3.HTMLUnit
4.hudson
5.junit
6.performance
7.plugin
8.profile
9.selenium
10.Tools
11.unit test
Java Testing Q&A » junit » hamcrest 

1. Multiple correct results with Hamcrest (is there a or-matcher?)    stackoverflow.com

I am relatively new to matchers. I am toying around with hamcrest in combination with JUnit and I kinda like it. Is there a way, to state that one of ...

2. Hamcrest's hasItems    stackoverflow.com

Why does this not compile, oh, what to do?

import static org.junit.Assert.assertThat;
import static org.junit.matchers.JUnitMatchers.hasItems;

ArrayList<Integer> actual = new ArrayList<Integer>();
ArrayList<Integer> expected = new ArrayList<Integer>();
actual.add(1);
expected.add(2);
assertThat(actual, hasItems(expected));
error copied from comment:
cannot find symbol method assertThat(java.util.ArrayList<java.lang.Integer>, org.hamcreset.Matcher<java.lang.Iterable<java.util.ArrayList<java.lang.Integer>>>)

3. Ant + JUnit: NoClassDefFoundError    stackoverflow.com

Ok, I'm frustrated! I've hunted around for a good number of hours and am still stumped. Environment: WinXP, Eclipse Galileo 3.5 (straight install - no extra plugins). So, I have a simple ...

4. Hamcrest's lessThan doesn't compile    stackoverflow.com

Trying to compile this code

import static org.hamcrest.Matchers.is;
import static org.hamcrest.number.OrderingComparison.lessThan;

...

Assert.assertThat(0, is(lessThan(1)));
issues this compilation error:
assertThat(Object, org.hamcrest.Matcher<java.lang.Object>) cannot be applied to (int, org.hamcrest.Matcher<capture<? super java.lang.Integer>>)
Could be this collisions ...

5. Hamcrest equal collections    stackoverflow.com

Is there a matcher in Hamcrest to compare collections for equality? There is contains and containsInAnyOrder but I need equals not bound to concrete collection type. E.g. I cannot compare Arrays.asList and Map.values ...

6. Do any tools use the hamcrest Factory annotation?    stackoverflow.com

I sat down to write a matcher today and decided to take a quick look at the jmock documentation to refresh my memory on the process, and noticed a reference to ...

7. Checking that a List is not empty in Hamcrest    stackoverflow.com

I was wondering if anyone knew of a way to check if a List is empty using assertThat() and Matchers? Best way I could see just use JUnit: assertFalse(list.isEmpty()); But I was hoping that ...

8. Is there a version of JUnit assertThat which uses the Hamcrest 'describeMismatch' functionality?    stackoverflow.com

In every version of JUnit I have tried (up to 4.8.1), a failing assertThat will display an error message that looks like: expected: [describeTo]
got: [String representation of object] In other words, it will ...

9. How to use JUnit and Hamcrest together?    stackoverflow.com

I can't understand how JUnit 4.8 should work with Hamcrest matchers. There are some matchers defined inside junit-4.8.jar in org.hamcrest.CoreMatchers. At the same time there are some other matchers ...

10. Why junit included part of hamcrest in binary, but not in source    stackoverflow.com

Ok, so here is the place to download junit. Open any compiled jar - there is package org.hamcrest. Open any source-jar - there is no such package. It is very ...

11. Junit and Hamcrest Licenses    stackoverflow.com

I did a bit of research and I have noticed that Junit ships under CPL, Common Public License, whereas Hamcrest under BSD license 2 clauses (commonly called FreeBSD). My question is: If I want ...

12. Getting "NoSuchMethodError: org.hamcrest.Matcher.describeMismatch" when running test in IntelliJ 10.5    stackoverflow.com

I'm using JUnit-dep 4.10 and Hamcrest 1.3.RC2. I've created a custom matcher that looks like the following:

public static class MyMatcher extends TypeSafeMatcher<String> {
    @Override
    protected boolean ...

13. Using assertArrayEquals() with wildcards?    stackoverflow.com

I want to test code that produces byte arrays used to send as UDP packets. Although I'm not able to reproduce every byte in my test (e.g. random bytes, timestamps), I'd like ...

14. Hamcrest assertThat ambiguous?    stackoverflow.com

I got some samplecode from a college, imported the project and try to run the Tests: The method assertThat(Integer, Matcher) is ambiguous for the type MyClass Every assertThat is marked red with the ...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.