jamesmintram

jamesmintram

What I was looking for was a way to run a bunch of tests against a staging environment using “real” HTTP requests.

How would someone go about organising code in a Phoenix project for something like that? I am assuming it wouldn’t go under the standard test folder, as these tests are ran very seldom (and require a “real” webserver to test against) but I would like to use ExUnit to manage them.

An ideal solution for me would be something like:

mix test.acceptance http://staging-url

Is there something already like that?

Any suggestions or comments would be greatly appreciated.

Showing Posts 1 to 5

stefanchrobot

stefanchrobot

This totally sounds like something doable. Wouldn’t just using ExUnit with any HTTP client do the job for you?

On a side note, I would wonder what do you want to achieve, really. I would assume that you’re writing controller tests, so aren’t you duplicating the work? In a previous project we had controller tests and some “integration” tests written using Postman. The idea was that Postman could generate API docs out of the tests suites. The downside was that Postman’s project sync was a real pain and there was a lot of duplication between tests.

jamesmintram

jamesmintram OP

Thanks stefan.

Wouldn’t just using ExUnit with any HTTP client do the job for you?

That’s what I was thinking (and wondered if other people did the same) but I am not sure how best to integrate that into a phoenix project. My thoughts were to create a special mix command for running them.

On a side note, I would wonder what do you want to achieve, really.

I did think about this. The idea of these tests would be a sort of smoke test. They would test client journeys that contain a sequence of actions a client may carry out against the service, for example:

  • sign up
  • authenticate
  • create a resource
  • trigger a workflow
  • trigger another workflow

These steps would test high level functionality across many facets of the service in 1 test, only communicating via the REST interface. They test the happy path. I believe I first saw this idea in “Growing Object Orientated Software”.

stefanchrobot

stefanchrobot

So it looks like you want to bundle a suite of smoke tests with your app so that when you deploy it you can run it on the server. Did it get that right? If that’s the case, then using HTTP client with ExUnit’s assertions wrapped in a mix task makes sense.

Otherwise I’m not sure why you’d like to integrate those tests with your Phoenix project. The tests can be a totally separate Elixir project. I’d also consider using a different technology for that.

jamesmintram

jamesmintram OP

So it looks like you want to bundle a suite of smoke tests with your app so that when you deploy it you can run it on the server. Did it get that right?

Yes. Although the tests don’t need to ship with the app. (They can be left out when doing a prod build)

Otherwise I’m not sure why you’d like to integrate those tests with your Phoenix project.

My reasoning is to keep the tests and project together. I’d rather manage 1 repository than 2. Also, the changeset history will all remain in 1 timeline.

I’d also consider using a different technology for that.

I have done that in the past, using Python + HTTPie. It was OK, but you end up needing two environments on your machine, and you are dealing with switching between two languages. I would much prefer everything in 1 language.

using HTTP client with ExUnit’s assertions wrapped in a mix task makes sense.

OK, that’s great. I will probably create a separate Elixir project next to the existing one. That way they share nothing and I can keep them versioned together.

Thanks.

devonestes

devonestes

I’ve used Wallaby for that in the past, since it spins up an actual server. That, plus tagging those tests as acceptance tests or something, can totally do what you’re looking for.

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews