espec icon indicating copy to clipboard operation
espec copied to clipboard

Run ExUnit and Espec at the same time

Open lorenzosinisi opened this issue 5 years ago • 6 comments

Hello @antonmi , what is the best way to run ExUnit tests with an app that also has espec files?

I am trying to figure it out because I am working on an application which has one exunit file (an planning to add more) and some espec files. What is the best way to configure and run them both? or even with different commands?

I tried the following:

mix cmd --app app_name mix test file_name_test.exs but of course no success as it compains about ExUnit not being started

lorenzosinisi avatar Jun 10 '20 08:06 lorenzosinisi

Hey @lorenzosinisi ! ESpec itself also has both exunit and espec tests. What I do (locally and in CI) is just running two commands: ‘mix test’ and ‘mix espec’. See ‘.travis.yml’ file.

antonmi avatar Jun 10 '20 14:06 antonmi

aright, thank you :) I was looking for a way to run both but maybe an alias would do the trick here

lorenzosinisi avatar Jun 10 '20 14:06 lorenzosinisi

Hey @antonmi! Is it possible to replace exunit with espec?

alec-c4 avatar Jan 19 '23 17:01 alec-c4

Hey @alec-c4 ! Not sure, if I got your question. ESpec is an alternative test framework for Elixir. You can rewrite your tests using ESpec. You can do the transition gradually, using both exunit and espec.

antonmi avatar Jan 20 '23 09:01 antonmi

@antonmi I'll try to explain. If you've worked with Ruby on Rails before, you maybe know that you can create an application with key

  -T, [--skip-test], [--no-skip-test]                        # Skip test files

Which allows you to create app without tests, then use rspec with. Unfortunately, there are no similar option in Phoenix, so we are unable to create project without ex_unit and to use espec instead. That's why I'm askin' 'bout complete replacement of exunit with espec

alec-c4 avatar Jan 20 '23 09:01 alec-c4

@alec-c4 ! Got it. Yeah, phoenix creates default configs for ExUnit, however it doesn't force you to use ExUnit. Just delete test folder and setup ESpec

antonmi avatar Jan 20 '23 10:01 antonmi