Skip to content

Add ExUnit.run/1 to rerun test modules #11788

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 1, 2022
Merged

Conversation

kw7oe
Copy link
Contributor

@kw7oe kw7oe commented May 1, 2022

This PR add ExUnit.rerun/1 to rerun tests given a list of test modules.

Context

Often times, when writing a tutorial in Livebook, I want to write a test case for
the users so they could interactively write some code to make it pass. This is especially
helpful when we use Livebook as a teaching medium.

Currently, there are no ways to support ruruning a test without rewriting it.

Proposed solution

Add ExUnit.rerun/1 to take in a list of test modules to be rerun:

defmodule SampleTest do
  use ExUnit.Case
  
  test "true" do
     assert false
  end
end

ExUnit.rerun([SampleTest])

For more, refer to the proposal in the mailing list

kw7oe added 2 commits May 1, 2022 20:57
- Register `:ex_unit_async` module attributes as persisted attributes
  to allow us to the info through `Module.__info__(:attributes)`
  callback.
- This in turn allow us to add provided modules as sync/async
  conditionally.
Returns a map containing the total number of tests, the number
of failures, the number of excluded tests and the number of skipped tests.
"""
@spec run() :: suite_result()
def run do
@spec run(list(atom)) :: suite_result()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the spec change, do we need to add the since attribute?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question but I don't think so! We can mention this difference in the docs. :)

@josevalim josevalim changed the title Add ExUnit.rerun/1 to rerun tests. Add ExUnit.run/1 to rerun test modules May 1, 2022
@josevalim josevalim merged commit 5e07218 into elixir-lang:main May 1, 2022
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants