obmarg / ex_unit_fixtures

A library for defining modular dependencies (fixtures) for ExUnit tests.
MIT License
13 stars 5 forks source link

Module scoped fixtures should not autoload. #31

Closed obmarg closed 8 years ago

obmarg commented 8 years ago

Currently when you declare a module scoped fixture, it'll be created in the setup_all function of any test module that it gets imported into. This is fine for a first pass, but it'd be good to make sure that it only actually gets created for test modules that specifically require it.

There's 2 ways I can see this working:

  1. We create a module-specific "fixture store" that can store module scoped fixtures that have been created for this module. When we encounter a test that requires a module scoped fixture it could get stored in here, ready for re-use by other tests. This would be broadly similar to what we'd need for #15. The setup_all on_exit function of a module could shut this down.
  2. We somehow find a way to register which fixtures are used in a module, and then use that in the setup_all.

I think I prefer option 1, but be good to think about it.