This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-10-27
Channels
- # aleph (2)
- # beginners (19)
- # boot (15)
- # cider (1)
- # cljsrn (1)
- # clojure (68)
- # clojure-austin (12)
- # clojure-dev (2)
- # clojure-france (6)
- # clojure-italy (46)
- # clojure-russia (45)
- # clojure-spec (55)
- # clojure-uk (41)
- # clojurescript (117)
- # component (15)
- # cursive (54)
- # datomic (24)
- # events (2)
- # funcool (1)
- # instaparse (4)
- # klipse (30)
- # lein-figwheel (3)
- # leiningen (4)
- # luminus (4)
- # om (10)
- # onyx (13)
- # parinfer (36)
- # proton (1)
- # reagent (1)
- # ring (2)
- # ring-swagger (1)
- # rum (19)
- # test-check (6)
- # testing (9)
- # untangled (1)
Anybody got a tutorial or some knowledge on how to test a component and interact with it in the repl?
Or is the idea to test the system as a whole and the components will get tested as the system gets tested?
Currently the only way in my system is through HTTP and MQTT.
in the repl, just start the component: (def db-component-instance (component/start my-component))
there is nothing special you need to do to test them, other than just start them and pass it to the function that needs to use it.
@tetriscodes You can create (and test) any individual component in the REPL (and the Component docs give examples). Not quite sure what you’re asking…?
Just what is best practice, Test the Components vs Test the system’s surface
@seancorfield I coudnt find the docs. I see very little on the github readme about testing
So much is going to depend on what the component actually is. Mostly, components are just some data / state with initialization (and possibly termination) code.
In general you’re going to be testing functions that depend on components (i.e., take components as arguments).
So you don’t really “test the component”, except insofar as you can test that it starts / stops correctly.
The docs for Component say that you don’t pass the entire system around everywhere in your code, only the subcomponents that are needed by a particular set of functions. When you’re testing those functions, you only need the subcomponent so you can create just that part with system-map
sometimes, or the “constructor” function for the record that has your start/stop functionality.
Does that help? If not, can you be more precise about what you’re asking…?
for example, how would you test a database connection in another programming language? You don’t really, at least I have never done that. In component, you might have a Database component that holds a connection (or pool of connections) to a database that other parts of your system depend on to communicate with the database. If I felt the need to test a Database component, for example, I would probably just inspect its properties to see if a connection was open, and then close it and verify that it was closed. There really isn’t much to test. The other way, which is probably done more than once through out the system, is to only test those functions that depend on the database component.