About the author

My Photo

Java, Scala, and everything

Friday, November 2, 2012

FEST Assertions for Joda Time

Do you write unit tests? Of course you do. Do you use Joda Time? I think so. Do you use FEST Assertions? You should try it if you haven't yet. With FEST Assertions we can write fluent code like this:
Now let's assume we have some functions that return joda DateTime, and we want to test it. Can we do this in FEST Assertions?
No, we can't :( FEST Assertions don't handle Joda Time classes. However, do not worry :) At SoftwareMill we have written our own TimeAssertions for that :) So you can write your code like this:
TimeAssertions works for org.joda.time.DateTime, java.util.Date and org.joda.time.LocalDateTime. You can freely exchange DateTime and Date, i.e. you can compare DateTime to Date, DateTime to DateTime etc. LocalDateTime can be compared only to instances of the same class, as it doesn't make sense to compare it to DateTime or Date without specifying the time zone. TimeAssertions is available on github. If you want to use it from Maven project, add repository:
    <name>SoftwareMill Releases</name>
And dependency:
Happy testing!


Tomasz Nurkiewicz said...

Worth to mention that Fest 2.0 supports assertions on standard Java Date class.

Can you consider moving your great contribution to root Fest project so it's available out-of-the-box?

pawelstawicki said...

Cmon, who uses java.util.Date this days :P

Contributing to Fest 2.0 is a good idea, I'll try. Thanks!

Paweł Włodarski said...

Spoko, to będzie przydatne. Macie jeszcze jakieś ciekawe rzeczy w tych utilsach?


pawelstawicki said...

@Paweł Nie wiem co jest dla Ciebie ciekawe. Kod jest ogólnodostępny, więc zapraszam do sprawdzenia.

Paweł Włodarski said...

ej nie macie takiej supermarketingowej prezentacji - "softwaremill-test-util - I NIC NIE BĘDZIE NIGDY TAKIE SAMO!" ? :D

akmal niazi khan said...

This blog awesome and i learn a lot about programming from here.The best thing about this blog is that you doing from beginning to experts level.

Love from World Records List