Closed amorfis closed 11 years ago
Hi Pawel,
In fest-assert-core, we don't want any dependency on third party libraries, instead we write separate assertions modules for this need. As an example, I have started writing assertions for guava although it is very basic for the time being.
Joda time was definitely on our modules roadmap, what I'm gonna do is creating a new module so that we can take your contribution.
Thanks !
Fest assertions for Joda Time project has been created ! It's here : https://github.com/joel-costigliola/fest-joda-time-assert
Thanks! I'll contribute to the module then. I took into account that you might not want joda dependency in the core :) On Nov 18, 2012 6:54 PM, "Joel Costigliola" notifications@github.com wrote:
Fest assertions for Joda Time project has been created ! It's here : https://github.com/joel-costigliola/fest-joda-time-assert
— Reply to this email directly or view it on GitHubhttps://github.com/alexruiz/fest-assert-2.x/pull/127#issuecomment-10488911.
Great ! FYI, I'll be off from next thursday to mid december (holidays ...), don't worry if you have no answer during this period. I'm closing this issue and let open a new one in fest-joda-time-assert.
Hmm... There is some problem with the separate modules. It is that when you use static method name assertThat(), you can't statically import it together with another module's method. E.g. JodaTimeAssertions.assertThat() and MultimapAssertions.assertThat(). You can't have statically imported two methods with the same name. So to use fest-guava-assert together with fest-joda-time-assert, one will have to write MultimapAssertions.assertThat() or JodaTimeAssertions.assertThat() and can't statically import both to just have to write assertThat() in each case.
No it works (at least for me), I have been able to run this test successfully from fest-examples after adding a static import for GUAVA.assertThat
:
package org.fest.assertions.examples;
import static org.fest.assertions.api.Assertions.assertThat;
import static org.fest.assertions.api.Assertions.entry;
import static org.fest.assertions.api.GUAVA.assertThat;
import static org.fest.assertions.examples.data.Ring.nenya;
import static org.fest.assertions.examples.data.Ring.oneRing;
import java.util.List;
import org.junit.Test;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import org.fest.assertions.examples.data.Ring;
public class MapAssertionsExamples extends AbstractAssertionsExamples {
@Test
public void map_assertions_examples() {
// ringBearers is a Map of TolkienCharacter indexed by the Ring they are wearing.
assertThat(ringBearers).isNotEmpty().hasSize(4);
// note the usage of Assertions.entry(key, value) synthetic sugar for better readability (similar to MapEntry.entry(key, value)).
assertThat(ringBearers).contains(entry(oneRing, frodo), entry(nenya, galadriel));
assertThat(ringBearers).doesNotContain(entry(oneRing, aragorn));
// Assertion on key
assertThat(ringBearers).containsKey(Ring.nenya);
assertThat(ringBearers).doesNotContainKey(Ring.manRing);
// Assertion on value
assertThat(ringBearers).containsValue(frodo);
assertThat(ringBearers).doesNotContainValue(sam);
ringBearers.clear();
assertThat(ringBearers).isEmpty();
// Test that we can import statically assertThat from twi different sources
Multimap<String, List<String>> actual = HashMultimap.create();
actual.put("Lakers", newArrayList("Kobe Bryant", "Magic Johnson", "Kareem Abdul Jabbar"));
actual.put("Spurs", newArrayList("Tony Parker", "Tim Duncan", "Manu Ginobili"));
assertThat(actual).containsKeys("Lakers", "Spurs");
}
}
can you show me a failing test ?
Hmm... it works for me too now. I could swear it wasn't working. Maybe some java versions differences? Nevermind, it works fine on Java 6.
Paweł Stawicki http://pawelstawicki.blogspot.com http://szczecin.jug.pl
On Tue, Nov 20, 2012 at 10:33 PM, Joel Costigliola <notifications@github.com
wrote:
No it works (at least for me), I have been able to run this test successfully from fest-examples after adding a static import for GUAVA.assertThat :
package org.fest.assertions.examples; import static org.fest.assertions.api.Assertions.assertThat;import static org.fest.assertions.api.Assertions.entry;import static org.fest.assertions.api.GUAVA.assertThat;import static org.fest.assertions.examples.data.Ring.nenya;import static org.fest.assertions.examples.data.Ring.oneRing; import java.util.List; import org.junit.Test; import com.google.common.collect.HashMultimap;import com.google.common.collect.Multimap; import org.fest.assertions.examples.data.Ring; public class MapAssertionsExamples extends AbstractAssertionsExamples {
@Test public void map_assertions_examples() { // ringBearers is a Map of TolkienCharacter indexed by the Ring they are wearing. assertThat(ringBearers).isNotEmpty().hasSize(4);
// note the usage of Assertions.entry(key, value) synthetic sugar for better readability (similar to MapEntry.entry(key, value)). assertThat(ringBearers).contains(entry(oneRing, frodo), entry(nenya, galadriel)); assertThat(ringBearers).doesNotContain(entry(oneRing, aragorn)); // Assertion on key assertThat(ringBearers).containsKey(Ring.nenya); assertThat(ringBearers).doesNotContainKey(Ring.manRing); // Assertion on value assertThat(ringBearers).containsValue(frodo); assertThat(ringBearers).doesNotContainValue(sam); ringBearers.clear(); assertThat(ringBearers).isEmpty(); // Test that we can import statically assertThat from twi different sources Multimap<String, List<String>> actual = HashMultimap.create(); actual.put("Lakers", newArrayList("Kobe Bryant", "Magic Johnson", "Kareem Abdul Jabbar")); actual.put("Spurs", newArrayList("Tony Parker", "Tim Duncan", "Manu Ginobili")); assertThat(actual).containsKeys("Lakers", "Spurs");
} }
can you show me a failing test ?
— Reply to this email directly or view it on GitHubhttps://github.com/alexruiz/fest-assert-2.x/pull/127#issuecomment-10574069.
Hello,
I added some assertions for Joda Time types. Taken from https://github.com/softwaremill/softwaremill-common/tree/master/softwaremill-test/softwaremill-test-util (which I also authored). Please check it out.
Best regards Paweł Stawicki