medikent

medikent

What should be first, `Test.AppName` or `AppName.Test` for test modules?

If we are to include the label Test Anywhere in a test module name like

  • MyApp.Test.MyTestFile or
  • MyAppWeb.Test.MyTestFile,

which is the default, and since the test files are typically located under the test/ root level folder should we not begin all module names with Test?

This would mean:

  • Test.MyApp.MyTestFile and
  • Test.MyAppWeb.MyTestfile

Is the main argument for putting everything with app name first just to namespace all the test modules?

It is inconsistent to not follow the directory structure convention while also including the .Test. text in the middle a module name. The tests can already be identified by the ...Test ad the end of the file name.

Thoughts?

Most Liked

NobbZ

NobbZ

As far as I remember, the filename has to match the glob *_test.exs, while the module names need to end in Test, so placing it anywhere else would be redundant.

The way ex unit discovers the tests answers your question.

kokolegorille

kokolegorille

If You use to_string, You will see the real nature of module’s name.
This is one of mine…

to_string Pr3f.Application 
"Elixir.Pr3f.Application"

There is no correspondance with the name You give and related file system. It is very flexible and You could give any name, in any directory, that would be just fine. Convention is to do what You prefer :slight_smile:

But for test, convention is to not use Test as a directory, but as MyApp/MyFileTest. And don’t forget they are just scripts… as they have exs extension. They are not compiled.

kokolegorille

kokolegorille

I was not very explicit, I follow the convention to put test files in test directory.

What I meant is I don’t use Test inside the test module name, but as a suffix.

Where Next?

Popular in Discussions Top

Nvim
Anybody knows a comprehensive comparison of Django and Phoenix, thanks for the help. Where are they similar? Where do they differ the m...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 53690 245
New
sashaafm
Piggy backing a bit on @dvcrn topic BEAM optimization for functions with static return type?, I’ve been trying to understand in a deeper ...
New
Crowdhailer
I’ve been hearing much about the new formatter and it’s something I have been keen to try. I find examples buy far the most illuminating...
248 19204 150
New
AstonJ
I’ve just started the Phoenix part of the utterly brilliant online course by @pragdave. On generating the Phoenix app he uses the --no-ec...
New
CharlesO
Erlang :list.nth simple, but 1 - based nth(1, [H|_]) -> H; nth(N, [_|T]) when N > 1 -> nth(N - 1, T). Elixir Enum.at … coo...
New
crabonature
I’m still quite new to Elixir. As I understand we got in Elixir “multi guards” as convention to simplify one large guard with or’s?: de...
New
New
restack_oslo
Hello, Please pardon me for any faux paux. I am 46 and this is my first time on a forum of any kind. I wanted to to get answers from tho...
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New

Other popular topics Top

mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
johnnyicon
Hi all, I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I’m trying to use Postgres...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 53690 245
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
klo
Got a question about when to concat vs. prepending items to list then reversing to achieve appending. So i know lists boil down to [1 | ...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 47930 226
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

We're in Beta

About us Mission Statement