Fork me on GitHub
#component
<
2017-08-12
>
eronalves16:08:08

Hi! How do you testing components today? I search a lot and see fews examples dated from 2014-2015. Do you using macros or other approach? How do I do if I want to isolated my components to unit test? Do I need always start my full system?

noisesmith16:08:48

why would a macro help?

noisesmith16:08:25

components naturaly isolate - you just pass in alternates for each key they want to use, and it's isolated from the other components

noisesmith16:08:40

and no, I would never start the whole system in a test, just the component being tested

eronalves17:08:17

I saw this link about the macro with-components https://github.com/stuartsierra/component/issues/6

eronalves17:08:08

Understood. Thanks @noisesmith.

eronalves17:08:43

More one question, sorry if I’am inconvenient, but I started to learn Clojure a few months. Is this approach ideal to isolate my component and test the life cycle and public api?

noisesmith17:08:35

yes, and usually a component needs other components that you would want to associate as keys onto component

noisesmith17:08:56

but since they will likely be test stubs, you can just directly attach them as keys - you can use map literals to create small one time use components with the values you need in them, component just passes a map on unchanged