atoum / AtoumBundle

This bundle provides a simple integration of atoum into Symfony 2.
MIT License
44 stars 25 forks source link

Improved test syntax with fluent API #8

Closed jubianchi closed 11 years ago

jubianchi commented 11 years ago

What do you think of something like that ?

https://github.com/jubianchi/AtoumBundle/tree/custom-asserters#test-a-controller

stephpy commented 11 years ago

:+1:

Uses of a library like guzzle would be great.

FlorianLB commented 11 years ago

Yeah ! I use something like that in my pro projects but without the fluent interface.

Why Guzzle ? Symfony crawler is quite good for testing API.

stephpy commented 11 years ago

@FlorianLB you are right, let's stay on symfony context, i used guzzle and i found this library very useful but crawler will be sufficient.

jubianchi commented 11 years ago

The crawler could also be abstracted to let the end user choose which one he wants to use.

stephpy commented 11 years ago

:+1: @jubianchi

ludofleury commented 11 years ago

This is really nice. Since it's a Symfony bundle, the hard requirement of the Symfony crawler is okay. Yet we could enhance this later with an Interface Requirement or something like that :)

Good job.

jubianchi commented 11 years ago

I added a gist (https://gist.github.com/4336789) where I'll put updated examples while I'm working on this PR.

jubianchi commented 11 years ago

I updated the gist linked in my previous comment with some cool stuff.

As I did in another PR on atoum (https://github.com/atoum/atoum/pull/151), I had to rely on an end keyword to trigger assertions. I am not a big fan of this but it's really difficult to avoid using something like this and keep the navigation in the DOM tree easy.

At the moment, I don't know how to do things without this keyword. In some cases, the end keyword can be omitted but, again, I don't like this because it breaks an atoum's principle : intuitive.

What do you think of this end thing ?

Another thing that can be omitted : you can avoid typing the exactly assertion if you expect to find only one element.

stephpy commented 11 years ago

IMO end keyworld should not be a problem ... It looks like a tree, end is useful for us and for user to easily see which node is related.

Awesome work @jubianchi ;)

FlorianLB commented 11 years ago

There is a BC ($kernel in Test\Units\WebTestCase) but i guess we can deal with it with a tag.

Nice job, ready to merge ?

jubianchi commented 11 years ago

@FlorianLB I think it's good to merge but it's missing an asserter on the headers. I'll write it ASAP.

By the way, if you want to merge this as is, ou can but I think it would be better to give it a try by checking ou the branch locally and using it in some tests.

and a review of the code would also be really nice too ;)

jubianchi commented 11 years ago

My previous comment is wrong : after reviewing my commit I saw I already wrote the missing headers asserter.

Sorry, I'm a bit confused as I'm tired and sick :s

stephpy commented 11 years ago

Awesome work ! :+1:

FlorianLB commented 11 years ago

I did some review/tests, looks fine. It can be improved to be extend more easily (add new HTTP verbs, use a custom response asserter, etc) but can be done in a second time.

I will try to add some docs tonight.

Go merge ?

jubianchi commented 11 years ago

ok go :)

stephpy commented 11 years ago

Let's go \o/

stephpy commented 11 years ago

Thank you @jubianchi ;)

Swop commented 11 years ago

Nice work ;-)

gyndav commented 11 years ago

Nice one @jubianchi