Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Unit test question. Which is better?

  • 30-01-2002 2:26pm
    #1
    Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭


    1. Create unit test on class/method basis.

    2. Create unit test on functional area.


    eg.

    If you have two methods say one to open a file and another to close a file, would you create two tests or one test with both methods?

    I would guess one test as you would be duplicating? On the other hand having the one test means you don't group tests easier? Or am I thinking wrong?


Comments

  • Registered Users, Registered Users 2 Posts: 16,414 ✭✭✭✭Trojan


    You have to make sure you know what failed when failures occur: if the tests are too complex (i.e. when done functionally) then you may run in to difficulty, e.g. did the close fail cos the file never opened?

    With that in mind, I think functional grouping would seem reasonable, making sure to segregate important tests... what do you think?

    Al.


  • Closed Accounts Posts: 411 ✭✭Jay


    It depends on how intensive the testing must be.

    If you just want to know if it worked, then a simple Back box testing method would be sufficient, ie. test the functionality of class/program at once.

    With that in mind, you should be using some form of error logging so that you know WHERE the failure occured as opposed to just knowing that it failed.

    If you are using logging then I'd just go ahead and test the functionality.

    The most important thing is knowing WHERE the failure occurs. That's why logging is essential when it comes to testing.


  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    I'm using JUnit to do the unit testing. :)

    I don't think there is any right or wrong answer, just trying to think if I would run into any problems further down the line if I select one method over the other.

    Btw, if a test is too complex it would be more a functional test then a unit test? I normally have them seperate.


  • Registered Users, Registered Users 2 Posts: 16,414 ✭✭✭✭Trojan


    Originally posted by Hobbes
    I'm using JUnit to do the unit testing. :)

    huh?

    some lame-ass application programming tool, eh? :rolleyes:

    Originally posted by Hobbes

    Btw, if a test is too complex it would be more a functional test then a unit test? I normally have them seperate.

    I think that there must be a stage of complexity where it is no longer a system test.

    Al.


  • Closed Accounts Posts: 77 ✭✭paddymee


    I had a 4 hour cat fight last night with the "Senior Developer" in my new company when I found out that he feels his job is to write code and if it compiles, ship it.

    Needless to say the quality of the product here is ****e.

    Personally I don't do much official unit testing. But as I write the code I test each code path through it.

    I tend to take a bit longer to "churn" code out, but my code is usually very reliable.

    The bigger problem I find is that what I wrote and what was "Really" requested don't match. So I try very hard to spec things out in advance to flush out these issues.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    Originally posted by Trojan


    some lame-ass application programming tool, eh?



    LOL show your ignorance. Next you'll tell me you have never heard of extreme programming. ;)

    http://www.junit.org/


    I think that there must be a stage of complexity where it is no longer a system test.



    Doing a wander around junit site, there is this doc that tries to distingush between unit and functional testing.
    The line between unit and functional testing

    Often it isn't clear where to draw the line between unit and functional testing. To be honest, it isn't always clear to me where this line is either. While writing unit tests, I have used the following guidelines to determine if the unit test being written is actually a functional test:

    - If a unit test crosses class boundaries, it might be a functional test.

    - If a unit test is becoming very complicated, it might be a functional test.

    - If a unit test is fragile (that is, it is a valid test but it has to change continually to handle different user permutations), it might be a functional test.

    - If a unit test is harder to write than the code it is testing, it might be a functional test.


  • Registered Users, Registered Users 2 Posts: 16,414 ✭✭✭✭Trojan


    Originally posted by Trojan
    I think that there must be a stage of complexity where it is no longer a system test.

    Of course, you know that I meant to say "unit test" there...
    Originally posted by Hobbes

    Originally posted by Trojan
    some lame-ass application programming tool, eh?

    LOL show your ignorance. Next you'll tell me you have never heard of extreme programming.

    Forgive my attempt to carry over humour from the other thread...

    and what's extreme programming? :)

    Al.


  • Registered Users, Registered Users 2 Posts: 897 ✭✭✭Greenbean


    Programming standing on a snowboard.


  • Registered Users, Registered Users 2 Posts: 1,509 ✭✭✭viking


    Base Jumping with your Laptop...


Advertisement