On 2012-06-11 08:20, Johan Haleby wrote:
> Hi,
>
> Thanks a lot for your interest and work! Do you think it's better to wait
> for version 2.0 of fest-assert? Do you know if everything would have to be
I planned to implement the idea with assertion with timeout directly
into fest-assert 2.0 [1]. I did some PoC, but later found awaitility
which seems to be suitable for that purpose (the wait..until part is
already implemented). My current PoC for awaitility is based on 2.0
branch (currently on milestone 5) and I will keep it in sync with 2.0.
Probably I would be a good idea to will with release the next version of
awaitility (if any :) ) after 2.0-final, but I see in those changed in
fest-assert a chance (opportunity) to make some incompatible changes to
make it easier to integrate with awaitility. So work should be rather
done in the same time.
[1] -
https://jira.codehaus.org/browse/FEST-475
> rewritten? Btw, do you have a usage example that demonstrates awaitility
> and fest-assert?
Yes, I wrote a few unit test to test my PoC. Sample test with integer
value to be put into AwaitilityTest.
@Test
public void shouldAssertWithTimeoutAssertionFromFest() throws Exception {
//given
new Asynch(fakeRepository).perform();
//when
awaitFest().untilCallFest(to(fakeRepository).getValue()).isGreaterThan(0);
//then
assertEquals(1, fakeRepository.getValue());
}
awaitFest (quick and dirty hack to make it testale) is a static method
in Awaitility:
public static FestConditionFactory awaitFest() {
return awaitFest(null);
}
public static FestConditionFactory awaitFest(String alias) {
return new FestConditionFactory(alias, defaultTimeout,
defaultPollInterval, defaultPollDelay,
defaultCatchUncaughtExceptions);
}
> Also, how should we deal with the integration of fest-assert and
> awaitility? Perhaps a good idea would be to extract the matcher
> implementations (Hamcrest and fest-assert) to different modules that depend
> on "awaitility-core". In this way it would also be possible to write a
> fest-assert 2.0 module when it arrives. I think this may be a good approach
> but it'll probably require a lot of work and unfortunately I don't have
> much of it nowadays :/
I was thinking about separate module with support for fest-assert to not
introduce new dependencies for people using only awaitility with
Hamcrest and to allow to optional support both fest-assert 1.4 and 2.0.
The separated core module could be even more useful, but I think in a
first/base version Hamcrest could stay in the base package.
> Regarding final methods it's not possible to get around that using
> reflection. You'll need byte-code manipulation and I don't think we want to
> go down that road..
That's bad. The problem with final methods was also the main problem
with my PoC in pure fest-assert. I hoped to be able to mitigate it
somehow. I will talk with people from fest-assert what do they think
about remove final keywords or if they have some other idea.
Regards
Marcin
>>> On Sat, Jun 2, 2012 at 1:57 PM, Marcin Zaj�czkowski <
msz...@wp.pl>
>> wrote:
>>>
>>>> On 2012-05-31 08:47, Johan Haleby wrote:
>>>>> Hi,
>>>>>
>>>>> I prefer to use fest-assert as well but it's not as flexible as
>> Hamcrest
>>>>> when it comes to using it in a third-party framework. But how do you
>>>>> "retake" the value from fest-assert in your second example? Perhaps
>>>>> something like this could work:
>>>>>
>>>>> await().untilCall(to(fakeRepository).getValue()).isEqualTo(5);
>>>>>
>>>>> I.e. untillCall returns the outcome of
>>>>> "assertThat(fakeRepository.getValue())" (assertThat is called
>> implicitly
>>>>> under the hood by awaitility).
>>>>
>>>> Thanks for a tip. I make a try to implement it, but unfortunately there
>>>> is a problem. I can "retake" value using proxy and apply it to
>>>> assertThat inside untilCall, but later I have to return value (the
>>>> result of assertThat(...)) to execute assertions (here isEqualTo()) and
>>>> I don't have control over it (I can't catch exception throws by
>>>> isEqualTo() and retry leter).
>>>> Maybe you have some clever idea how to achieve it?
>>>>
>>>> Regards
>>>> Marcin
>>>>
>>>>
>>>>> On Wed, May 30, 2012 at 3:38 PM, Marcin Zaj�czkowski <
msz...@wp.pl>