bennadel / Streamlined-Object-Modeling

I am currnently working through the book, Streamlined Object Modeling: Patterns, Rules, and Implementation. True object oriented programming (OOP) is a new world for me and it's really hard for me to wrap my head around. I'd like to get a nice set of code samples here that I can use to practice the modeling techniques outlined in the book.
25 stars 8 forks source link

Added Some Testing #4

Closed bennadel closed 10 years ago

bennadel commented 10 years ago

@jonahx Over the weekend (and this morning), I tried to add some unit-testing-like features to the main.js file:

https://github.com/bennadel/Streamlined-Object-Modeling/blob/master/examples/01-social-circle/js/main.js#L28

It's basically a collection of assert statements that make sure the gets, sets, and relationships are working. It was cool - I even found a bug in the love-triangle logic that only tested one way and not the other.

jonahx commented 10 years ago

Looking good. Have you ever used jasmine for unit testing before?
It's nice:

http://pivotal.github.io/jasmine/

Not fundamentally different from what you're doing here, but would make things cleaner. Worth checking out, anyway.

On Monday, October 21, 2013 3:51:46 PM, Ben Nadel wrote:

@jonahx https://github.com/jonahx Over the weekend (and this morning), I tried to add some unit-testing-like features to the main.js file:

https://github.com/bennadel/Streamlined-Object-Modeling/blob/master/examples/01-social-circle/js/main.js#L28

It's basically a collection of assert statements that make sure the gets, sets, and relationships are working. It was cool - I even found a bug in the love-triangle logic that only tested one way and not the other.

— Reply to this email directly or view it on GitHub https://github.com/bennadel/Streamlined-Object-Modeling/issues/4.

bennadel commented 10 years ago

@jonahx I've played with Jasmine only once before. Unit testing is something that I am relatively new to. I created a ColdFusion unit testing framework to learn more about it - TinyTest. But, as far as JS is concerned, I don't really have any testing practices down. The one thing that bugs me a bit about most testing frameworks that I've seen is that they seem very verbose.

It's probably a mind-set thing. I think a lot of people look at Unit Tests like "documentation". I simply look at them like things that have to run without error.

I'm sure that as I get more used to unit testing, I'll adjust my perception!

jonahx commented 10 years ago

Yes, they are a bit verbose, pretty much all of them. At least ones like Jasmine score high on readability (somewhat close to English itself).

Also -- and this is not to say there isn't room for improvement -- at some point you run into the limits of your expressiveness (or perhaps the limits of your intuition about scope), and realize that putting all the rules of a system down on paper, even in English, takes up a good chunk of space. Think about the readme for this simple project. That is to say, to some extent, the system itself is more "verbose" than one originally thinks.

This may be partly TDD apologism, but I do think there's some truth to it.

On Monday, October 21, 2013 4:05:21 PM, Ben Nadel wrote:

@jonahx https://github.com/jonahx I've played with Jasmine only once before. Unit testing is something that I am relatively new to. I created a ColdFusion unit testing framework to learn more about it - TinyTest https://github.com/bennadel/TinyTest. But, as far as JS is concerned, I don't really have any testing practices down. The one thing that bugs me a bit about most testing frameworks that I've seen is that they seem very verbose.

It's probably a mind-set thing. I think a lot of people look at Unit Tests like "documentation". I simply look at them like things that have to run without error.

I'm sure that as I get more used to unit testing, I'll adjust my perception!

— Reply to this email directly or view it on GitHub https://github.com/bennadel/Streamlined-Object-Modeling/issues/4#issuecomment-26719527.

bennadel commented 10 years ago

@jonahx what's ironic is that most of the time, people hate on me for the amount of comments that I put in my code; and yet, I find testing suits to be overly verbose -- some sort of bizarro world ;)

jonahx commented 10 years ago

haha, i did notice that. i also noticed all the whitespace... i think you'd like living in montana :)