Skip to content
This repository has been archived by the owner on Sep 5, 2018. It is now read-only.

Testing Guide #99

Closed
lancehalvorsen opened this issue Dec 23, 2014 · 12 comments
Closed

Testing Guide #99

lancehalvorsen opened this issue Dec 23, 2014 · 12 comments

Comments

@lancehalvorsen
Copy link
Member

There have been several questions on the mailing list lately about how to test various parts of a Phoenix application. It would be great to have a guide as a reference.

@chrismccord
Copy link
Member

This would be really nice. Right now the best we have is telling folks to look at the tests in the Phoenix suite. Maybe we can extract some of that into a general testing guide? Phoenix will eventually provide a Phoenix.Test helper module for easier testing, but we have some other things to tackle first.

@jeregrine
Copy link
Member

Since @josevalim did such a nice job with ConnTest we should be able to tackle this one.

@josevalim
Copy link
Member

Thank you! Channel test should come this weekend. We also have ModelCase on
v0.12.0z

José Valimwww.plataformatec.com.br
http://www.plataformatec.com.br/Founder and Lead Developer

@lancehalvorsen
Copy link
Member Author

👍 to the delights of ConnTest and ModelCase!

Also, since the generators now provide test files, getting folks up to speed on testing models and controllers will be significantly easier, I think.

Looking forward to having these conveniences on Channels as well.

@lancehalvorsen
Copy link
Member Author

I just opened up PR #238 as a skeleton for this.

I'm working on the intro now, and will head into the models and controllers in turn. The larger plan is to use the the HTML resource we built for ecto models as a jumping off place because a) folks should be familiar with the code already, and b) there are already tests in place that we can add on to. :^)

@gjaldon
Copy link
Contributor

gjaldon commented May 14, 2015

Would you like some help here, @lancehalvorsen? I've had the chance to use Phoenix.ChannelTest when working with the channel generator in Phoenix and have used ConnTest and ModelCase in an app I'm building.

@lancehalvorsen
Copy link
Member Author

Yes, please! Thanks so much for the offer, @gjaldon. :)

@lancehalvorsen
Copy link
Member Author

@gjaldon, I just closed this #152, but there may still be things you can use from it. @paulcsmith has kindly offered it up if it's useful.

@paulcsmith
Copy link

@gjaldon LMK if you need any help with the channel guide. As @lancehalvorsen mentioned, the one I started might be a good outline for the new one

@gjaldon
Copy link
Contributor

gjaldon commented May 15, 2015

@paulcsmith thanks! Will let you know if I get stuck and will likely use the one you started as outline.

@jsncmgs1
Copy link
Contributor

I'm going to start on a guide for Controller specs, specifically testing JSON responses. I personally never write controller tests if I'm rendering templates (I write feature tests), so if someone else would like to tackle that chunk that would be great. If not, I'll do it after I'm done with the JSON stuff.

Or perhaps the guide for testing non API controllers is a guide on features tests?

@jsncmgs1
Copy link
Contributor

jsncmgs1 commented Aug 16, 2016

Also, I feel like we should have a task list so we have a goal to work toward for closing this:

  • Controller Tests
  • Feature Tests ??

Given that Models and Channels already have a guide, I feel like once we have these checked off that's the core of what people are generally testing, and other things like Routes, Mailers, can have their own issues.

jsncmgs1 added a commit to jsncmgs1/phoenix_guides that referenced this issue Aug 20, 2016
This covers testing an API controller, there is nothing in here
for feature test style tests.
jsncmgs1 added a commit to jsncmgs1/phoenix_guides that referenced this issue Aug 20, 2016
This covers testing an API controller, there is nothing in here
for feature test style tests.
jsncmgs1 added a commit to jsncmgs1/phoenix_guides that referenced this issue Sep 18, 2016
This covers testing an API controller, there is nothing in here
for feature test style tests.
jsncmgs1 added a commit to jsncmgs1/phoenix_guides that referenced this issue Sep 18, 2016
This covers testing an API controller, there is nothing in here
for feature test style tests.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants