component

eronalves 2017-08-12T16:58:08.355749Z

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?

2017-08-12T16:58:48.359859Z

why would a macro help?

2017-08-12T16:59:25.363359Z

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

2017-08-12T16:59:40.364821Z

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

eronalves 2017-08-12T17:00:17.368986Z

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

eronalves 2017-08-12T17:01:08.374203Z

Understood. Thanks @noisesmith.

eronalves 2017-08-12T17:12:43.437402Z

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?

2017-08-12T17:16:35.458795Z

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

2017-08-12T17:17:56.466124Z

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

eronalves 2017-08-12T17:29:41.528545Z

Thanks a lot @noisesmith !