c# - How do you know what to test when writing unit tests? -


using c#, need class called user has username, password, active flag, first name, last name, full name, etc.

there should methods authenticate , save user. write test methods? , need worry testing properties since .net's getter , setters?

many great responses on question: "beginning tdd - challenges? solutions? recommendations?"

may recommend taking @ blog post (which partly inspired question), have got feedback on that. namely:

i don’t know start?

  • start afresh. think writing tests when writing new code. can re-working of old code, or new feature.
  • start simple. don’t go running off , trying head round testing framework being tdd-esque. debug.assert works fine. use starting point. doesn’t mess project or create dependencies.
  • start positive. trying improve craft, feel it. have seen plenty of developers out there happy stagnate , not try new things better themselves. doing right thing, remember , stop giving up.
  • start ready challenge. quite hard start getting testing. expect challenge, remember – challenges can overcome.

only test expect

i had real problems when first started because sat there trying figure out every possible problem occur , trying test , fix. quick way headache. testing should real yagni process. if know there problem, write test it. otherwise, don’t bother.

only test 1 thing

each test case should ever test 1 thing. if ever find putting “and” in test case name, you’re doing wrong.

i hope means can move on "getters , setters" :)


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -