Exunit - can value be passed to setup block?

Is there a way to pass value(s) to setup block?

I know I can give the “context” var and set values inside setup so that they propagate to the tests, which can consume them but I fail to see how a setup block could use value set outside of it. Am I missing something obvious or is it simply a no-no?

You can use tags or module attributes. Here is usage example

5 Likes

It doesn’t stop to amaze me how quick and helpful responses one gets in this community. Tags seem to fit my case very well

@tag my_key: my_value

setup context do
	IO.puts(context[:my_key])
end

proves this works. Thanks a lot!

2 Likes