Super-duper Overidded



  • I wish I could say that this code surprised me. This is part of a single test suite, composed of nearly 3,500 lines of code, all in a single file. Java, in case you're wondering, though that's not the WTF.

    		/**
    		 * Overridded setUp() method
    		 */
    		protected void setUp() throws Exception {
    
    			super.setUp();
    		}
    
    		/**
    		 * Overridded tearDown() method
    		 */
    		protected void tearDown() throws Exception {
    
    			super.tearDown();
    		}
    

  • 🚽 Regular

     Looks like it was auto-generated from a template or something. I think the bigger WTF is the original author is spelling "overridden" wrong.



  •  Maybe he had a cold? An ... um ... really really bad cold?



  • You just have shown the world you know nothing of inheritance, OOP or Java. Go read a book. And change account, it's embarrassing.
    And yes, it's generated code, inherits from JUnit Test Case.



  • @ubersoldat said:

    You just have shown the world you know nothing of inheritance, OOP or Java. Go read a book. And change account, it's embarrassing.
    And yes, it's generated code, inherits from JUnit Test Case.

    The overrides do nothing except add an extra stack frame to setUp() and tearDown() calls. They provide no additional functionality, and have no reason to exist. They are not auto-generated, because the tools we use here to not auto-generate worthless code. Looking at previous revisions, I find that this method has never contained any other code that would give a hint as to why it's still here.

    Assuming you're not a troll, you really need to follow your own advice a little.


  • 🚽 Regular

    @ubersoldat said:

    You just have shown the world you know nothing of inheritance, OOP or Java. Go read a book. And change account, it's embarrassing.
    And yes, it's generated code, inherits from JUnit Test Case.

    Let me guess, you also think he's an idiot, and should be banned from his mommy and daddy's modem?





  • @DemonWasp said:

    The overrides do nothing except add an extra stack frame to setUp() and tearDown() calls. They provide no additional functionality, and have no reason to exist.

    I'm a C# guy, but assuming the Java IDEs work similar to Visual Studio, these would give you a place to set a breakpoint...



  • I'm a C++ guy, but I agree with  RaspenJho.



  • Quite. I probably wouldn't do it myself - I'd probably go back and remove sauch methods, and I'd spell correctly - but I can see there may be reasons for doing this. Automatic unit test generation can be a good idea because it makes sure you don't forget any of the methods. Then you go back and fill in all the detail.



  • @Matt Westwood said:

    sauch methods, and I'd spell correctly



  • So it basically super.set you Up() just to super.tear you Down();

     That's just not cool.


Log in to reply