hubertlepicki

hubertlepicki

Integration testing Phoenix/umbrella app

So here’s the thing. I have an umbrella project with following apps:

  • ui - Phoenix application
  • core - my core business logic / services layer
  • storage - my Ecto schemas and such

I am really careful to write code in a way that upper layer only touches one layer below. For example, my ui app does not touch the storage app in any way.

I do want to, however, write integration (selenium) tests for the thing, that’d go top to bottom. As far as I can see it, I have a few options:

  1. Write integration tests in the ui app, mocking my core layer (ugh)
  2. Write integration tests in the ui app, mocking my storage layer (ugh)
  3. Write integration tests in ui app without mocking anything and putting up with the dependencies
  4. Create fourth integration app solely for the purpose of running tests.

Any other options? What would you do?

Most Liked

axelson

axelson

Scenic Core Team

@hubertlepicki what type of setup did you end up with? Are you using Mox in your integration tests? Probably not since Mox is more for unit testing.

A better question is how are you setting up the mocks so that you can use the mocks for unit testing but not use them for integration testing.

hubertlepicki

hubertlepicki

We went with full stack testing from our UI app. So we prepare database, open browser, it clicks around and does hit the database.

We did get with using Mox to test core app.

hubertlepicki

hubertlepicki

Right, so you most likely have an umbrella app. Umbrella apps share the configuration, so you end up with precisely the above problem.

Our app is just a folder with 3 apps now, and we require the core from ui as a dep (with path: "../core") in mix.exs, and do similar with core and db apps.

This allows us to have different configuration for test env: in core we use Mox, but in ui we don’t.

In a nutshell, we treat the other apps as if they were library dependencies. So we do have some duplication in configs, i.e. config for ui configures all 3 apps, config for core configures core and db etc.

There is a nice advantage of that: you test the db app in isolation from rest of the system, the core app is not aware at all about existence of ui. Nice bounded contexts :slight_smile:

Where Next?

Popular in Questions Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
LegitStack
I’m trying to make a websocket server in Phoenix or raw Elixir. I heard about gun, I think I could use cowboy, but since I’m not that sma...
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
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

Other popular topics Top

malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
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
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
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

We're in Beta

About us Mission Statement