How can I improve my junit tests

后端 未结 9 798
南笙
南笙 2020-12-05 08:59

Right my junit tests look like a long story:

  • I create 4 users
  • I delete 1 user
  • I try to login with the deleted user and make sure it fails
9条回答
  •  [愿得一人]
    2020-12-05 09:10

    In addition to the above, pick up a good book on TDD (I can recommend "TDD and Acceptance TDD for Java Developers"). Even though it will approach from a TDD point of view there is alot of helpful information about writing the right kind of unit tests.

    Find someone who has alot of knowledge in the area and use them to figure out how you can improve your tests.

    Join a mailing list to ask questions and just read the traffic coming through. The JUnit list at yahoo (something like groups.yahoo.com/junit). Some of the movers and shakers in the JUnit world are on that list and actively participate.

    Get a list of the golden rules of unit tests and stick them on your (and others) cubicle wall, something like:

    • Thou shalt never access an external system
    • Thou shalt only test the code under test
    • Thou shalt only test one thing at once etc.

提交回复
热议问题