alfert

alfert

How to use dynamic tags for excluding or including tests

Hi all,

I am working on my property based testing library propcheck. My latest feature is to re-run all failing properties (read: special test cases with their own macro definition) from the last test. So I write the failing property names to a file on disk and control the testing procedure in the next run depending on the file’s content. This works for now, but the reporting via ExUnit does not consider the skipped successful properties.

To achieve the regular ExUnit reporting, I generated a tag for each property in my macro with @tag failing_prop: true/false. The value of the tag depends on the last test run of this particular property. Log output shows that all tags of test module are evaluated before the tests are run, so this part works. But I never succeeded to filter out all properties which were successful at the last run (or vice versa to include only those which failed last time).

My questions are:

  • Is it generally possible to generate tags within a macro which sets value of the tag at runtime (= compile team of the .exs file)?
  • Is there any other possibility to inform ExUnit about skipped test cases (e.g. via an exception or a return value?
  • Is my macro construction regarding the tag simply wrong?

Here is the relevant snippet of the property macro:

quote bind_quoted: [name: name, block: block, var: var, opts: opts] do
      ExUnit.plural_rule("property", "properties")
      prop_name = ExUnit.Case.register_test(__ENV__, :property, name, [])
      %{module: module} = __ENV__
      if tag_property({module, prop_name, []}) do
        @tag failing_prop: true
      end
      def unquote(prop_name)(unquote(var)) do
        p = unquote(block)
        mfa = {unquote(module), unquote(prop_name), []}
        execute_property(p, mfa, unquote(opts))
        :ok
      end
  end

Thanks,
Klaus.

Where Next?

Popular in Questions Top

sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lists...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: The documentation above suggests that while ...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New

Other popular topics Top

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
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36432 110
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
jaysoifer
Is there a way to rollback a specific migration and only that one (“skipping” all the other ones)? Would mix ecto.rollback -v 200809061...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

We're in Beta

About us Mission Statement