librarian-clojure icon indicating copy to clipboard operation
librarian-clojure copied to clipboard

Test for librarian-clojure.core use cases

Open jaceklaskowski opened this issue 13 years ago • 8 comments

Tests for the following use cases (guess they should be separate issues - create ones if you think so):

  • Open the welcome page
  • Login as admin
  • Register as a new user
  • Logout as admin
  • logout as a new user

jaceklaskowski avatar Sep 02 '12 08:09 jaceklaskowski

I've took the opportunity to start fiddling with midje on that issue but I'm not sure if I understand it right - what one is supposed to test? When I take pure request/response check approach (as in case of existing tests), there's no distinction between login as user and login as admin when it comes to the outcome. In both cases the response is simple {:successful true}. The same with logout. Maybe what you meant is a sort of a full-blown selenium driven test?

zoldar avatar Dec 10 '12 22:12 zoldar

I don't want anybody to get burried setting up a test infrastructure for the project. The tests should be as simple as possible and let us introduce changes without worrying they break the project.

The tests should've been written before writing the code, but in this particular case it's gonna be different only when the tests deserve existence. If you think the tests are not necessary, mark the issue to be closed. It was just an idea to have more tests so others could join writing tests if they think that's the way to get involved.

What do you think?

jaceklaskowski avatar Dec 11 '12 15:12 jaceklaskowski

Going through history, I've realized that these tests (at least these in core) mainly conern routing, not the business logic. I'll try to look into that. I'm still struggling with proper testing (not only in clojure) so this will be an opportunity for me to do some sharpening in that aspect. Marick's way of doing TDD (as in his example tutorial on that game logic design) with Midje really feels right to me - maybe because of that strongly declarative approach.

zoldar avatar Dec 11 '12 16:12 zoldar

Can't wait till I see new tests coming in. Don't let me wait too long :-)

jaceklaskowski avatar Dec 11 '12 21:12 jaceklaskowski

Thought I would write some tests but I see that you're doing some cleaning up and test-related changes. Should I restrain from doing anything in that regard for now?

zoldar avatar Dec 26 '12 22:12 zoldar

Do it now. I'm finished for today. Use lein2 midje --lazytest while midje'ing as it will automatically execute the tests changed. Pull request once done (I spent a couple of hours trying to squash some autorization-related test issues, but couldn't get passed a line where response is supposed to be available - it's been nil)

jaceklaskowski avatar Dec 26 '12 22:12 jaceklaskowski

Just by the way (and sorry for off-topic) - "Create account" still doesn't bring up any overlay/dialog. Is that a problem awaiting for a fix or should it behave correctly by now?

zoldar avatar Dec 26 '12 22:12 zoldar

Needs a fix...and more importantly a test before an implementation :-) Everything's in the repo.

jaceklaskowski avatar Dec 26 '12 22:12 jaceklaskowski