Dexter

Dexter

I would like to run tests which are written in different files by calling mix test.
For example test1.exs, test2.exs, …
The ExUnit.start options are [trace: true, seed: 0 , exclude: :skipped] because the test must run in a given order.
It would be nice to include these files by some options or by calling them out of ProjectnameTest. Then I would be able to exclude tests by excluding a complete file.

Now I’m running them by calling them in a script with mix run test1.exs …
But this is not what we want because be would like this configuration in elixir centrally.

Showing Posts 1 to 10

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

You can do:

mix test test/some/path

and it will run all tests in that path. Is that not working for you?

Dexter

Dexter OP

No because the file are executed in random order. The option seed: 0 disables the random order only inside the file.

We are running integration tests for a system for which we have written a simulator to communicate with. Therefore we have dependencies like StartUp test has to run first.
I guess at the end of day we will have hundreds of tests where some of them will have strict dependencies. It will be very messy to write all tests in one single file.
Also we would like to sort the tests into categories to be able to activate or deactivate a special type of test.
I know you can do that also with @tag :skipped but this is also not very elegant in our case.

radar

radar

Do you have some example code that we could look at? Talking about it using just words is not as good as using words+code. I really think it’ll help our understanding of this issue.

Dexter

Dexter OP

I don’t get your point.
It has nothing to do with my code because the test are running if I put them in one file with the option seed: 0 and async: false. I “just” want to be able to run them in a given order.

file a_test.exs has test a1, a2, a3
file b_test.exs has test b1, b2, b3
file c_test.exs has test c1, c2, c3

The test should run for example in the following order.

a1, a2, a3, c1, c2, c3, b1, b2, b3 
radar

radar

You’re asking us to give you the solution for Y but you may need the X solution. I don’t think I have enough info on your problem to know for certain. This is why I asked for code.

If something seems hard to do then it can be because how you’re attempting it isn’t the right way.

Dexter

Dexter OP

We are not testing elixir code.
We have written a simulator in elixir which is communicating via serial interface with a device. The code of this divece is c++ -code.
The simulator simulates a motor control.
Now I would like to test this device via the serial interface.
If that device sends a message an event is triggered and we are checking if this was the right event.
It can not be compared to elixir unit tests.
Till now we have just some dummy tests. First we have to solve the above-mentioned problem.

bitboxer

bitboxer

If you are not writing tests for your elixir code, why then do you try to use mix test for it instead of an elixir script that you would call serial port tester´or something like that?

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

Agreeing with @bitboxer here, it sounds like you are using the wrong tool for the job. mix test is for testing against Elixir code. As a rule it is very bad practice to have order dependent tests because such tests are extremely brittle as they rely on quite a lot of invisible implicit state.

Dexter

Dexter OP

I fully agree that tests should run independently. But in our cases we have start up test which have to run first.
Nevertheless thank you for the discussion.

I’ve to learn the ropes of scripting in elixir.

alfert

alfert

You can also write a regular Elixir application, where the application start function orchestrates the test execution. And if helpful, you can use the supervision structure to achieve more reliability.

Where Next? Top

Trending in Questions Top

itzmidinesh
Hi all, I’m working on a Phoenix project where I need to make external HTTP requests and I’m trying to choose between Req and HTTPoison....
New
yarrichar
I’m very new to Elixir, so sorry if this is a silly question: I am wondering what happens to the mailbox of a process when the machine i...
New
Hellowman
Hello everyone! I am new to coding with Elixir/Erlang. And i am looking for some utilities for fuzzing testing like AFL++. Does anyone ...
New
pragdave
How do I tell Hologram not to escape HTML when substituting into templates? {Textile.render(@product.long_description)} escapes the HTM...
New
Fl4m3Ph03n1x
Background When trying to execute mix release on a Windows 11 machine for a Phoenix project I get the following error: * assembling mark...
New
rlipscombe
I’d like to create a file with 600 permissions (rw-------), but there’s a race condition if I create it and then change the permissions. ...
New
saleyn
Is there a way to import record definitions in the iex shell for pretty printing (similar to the rr command in the erl shell)? This woul...
New

Other Trending Topics Top

dominicletz
Hey there, I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first. ...
New
raa-ziq
Hi everyone :waving_hand: I wanted to share something I’ve been building — NowBlind, a random chat app designed to help people discover ...
New
mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
OndrejValenta
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly) AI dream has many faces, but general...
New
kip
Localize is the next generation localisation library for Elixir. Think of it as ex_cldr version 3.0. The first version will be released ...
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

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews