dwyl / phoenix-chat-example

💬 The Step-by-Step Beginners Tutorial for Building, Testing & Deploying a Chat app in Phoenix 1.7 [Latest] 🚀

Home Page:https://phoenix-chat.fly.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add More Tests?

nelsonic opened this issue · comments

At present we only have basic tests for this example ...
https://travis-ci.org/dwyl/phoenix-chat-example/jobs/372163015#L659
image

It's not very "exemplary" if half the app is untested ...
More detail: https://codecov.io/gh/dwyl/phoenix-chat-example
Thinking of adding a few more tests ... anyone up for "pairing" on this?

I've added a couple of extra tests and removed code that is not being used.
Now we're up to 94% which is much better than 59% ... ✅
https://travis-ci.org/dwyl/phoenix-chat-example/builds/373536612#L613
image

There is only ONE line not being covered:
https://codecov.io/gh/dwyl/phoenix-chat-example/src/b57cc174d7f1c9aac22947f23170b29d4c303776/lib/chat_web.ex#L65
image

I don't understand how to test this line ...
If it's not being executed I don't understand why removing the __using__ macro crashes the App.

If anyone else knows how to execute/test this line
I would be super grateful if you can share your wisdom!

Cross-posted the question to: https://elixirforum.com/t/why-how-when-to-use-the-using-which-macro-in-phoenix-controller-view-etc/14001

Now I go to sleep and in the morning the Wonderful Internet Elves have an answer for me. 😉

Got reply on forum: https://elixirforum.com/t/why-how-when-to-use-the-using-which-macro-in-phoenix-controller-view-etc/14001/2
and StackOverflow: https://stackoverflow.com/a/50127548/1148249
both are useful and I will read the shared links and reply ...

After much searching we concluded that it was not possible to test certain files
so we simple exclude them in the coveralls.json file:

"skip_files": [
"test/",
"lib/chat_web.ex"
]

We have been using this in all our Phoenix projects.