i was looking at some of the test code for the emma ant sensor. i didn't like how the thing was being tested, but couldn't really grasp how i would improve it. as usual, instead of wasting my time thinking by myself, i turn to someone for help. i've always find that explaining what i need help with to someone else almost always helps me solve the problem. not to mention that putting to heads together almost always solves the problem faster and better.
aaron: testing question.
aaron: the ant sensors are very procedural.
aaron: give it the file. it parses creates the keyvaluemap, adds to sensor shell and then sends.
aaron: testing something like this would require.. the test code to implement some parts of the procedure.
aaron: for example the test code would have to get the jaxbcontext then go through the procedure too.. to get to the keyvaluemap.
aaron: that seems really bogus. and is why the sensors aren't tested good.
aaron: how to fix that. ideally you would want to inspect at a certain period in time. like aspect style.
austen: i never learned aspects, but what you are saying sounds like what you would want to do conceptually. but you have to create some type of state in your testcase in order to figure out anything. this goes for alot of code you want to test. right?
austen: that bogus "fake" state is what you dont like?
aaron: ah.. so make a mock object
aaron: so build jaxb objects
aaron: send it in.
aaron: then get the results.
aaron: in parts.
aaron: i guess you can't test the whole procedural process.
aaron: thats a system test.
aaron: sound good?
austen: well i think in your case, you would just have some testdata
austen: and you would let the sensor run on that to create to the jaxb objects
austen: but more or less yes you wanna create some mock jaxb objects
aaron: okay.. i got it.
aaron: test data -> send to method -> get jaxb objects -> send to sensor logic portion -> get back keyvaluemap -> analyze values
austen: yah thats how you test if it loaded correctly if you had access to that keyValMap. but you gotta figure out a way to get access to it
austen: a problem with the sensor testing is you dont know if it gets sent
austen: and that sucks
austen: you kinda say ok it loaded it into sensorshell ok
austen: but is your sensor really sending it?
austen: *shrugs*
aaron: thats a system test.
austen: ah i see
aaron: k. i think i got it. good idea bouncing session.
this was a good discussion and got me on track on what i wanted to do. these are the types of little collaboration that need to be shared across a team. its is not profound, but it helps keep the software development at a high level by introducing 10 second vignettes of knowledge.
1 comment:
We would be lost without IM.
Post a Comment