Dacelonid wrote: » @Test public void testSomething(){ final String returnValue = ""; setupMock(); DBConnectionManager objUnderTest = new DBConnectionManager(); objUnderTest.doMethod(); assertNotNull(returnValue); } There was a bit more code that that in the test, but that was a general structure. I tried to explain the management and the offshore teams, that this wasn't actually testing anything, they didn't really get it.
@Test public void testSomething(){ final String returnValue = ""; setupMock(); DBConnectionManager objUnderTest = new DBConnectionManager(); objUnderTest.doMethod(); assertNotNull(returnValue); }
Maximus Alexander wrote: » Maybe what they were trying to test is whether or not a blank string is null? :pac:
GreeBo wrote: » I had someone tell me that they could delete a bunch of failing unit tests as "no one would notice and I'm sure no one knows what they do anyway"
Berserker wrote: » I've had that before. First thing in the morning someone notices that the tests have failed. Someone goes, "comment the failing tests out, so the tests all pass and all looks ok".
Dacelonid wrote: » Just on the topic of tests, last year I had to do an analysis of the unit tests on a ~4 year old project that was currently mostly being developed by an offshore team Apart from using @Ignore to turn off tests that were failing, or deleting asserts so that they wouldn't fail, or tests in the wrong class, or tests named for something stupid rather than what it was testing, the one that really stuck in my mind was something along these lines (method names are made up)@Test public void testSomething(){ final String returnValue = ""; setupMock(); DBConnectionManager objUnderTest = new DBConnectionManager(); objUnderTest.doMethod(); assertNotNull(returnValue); } There was a bit more code that that in the test, but that was a general structure. I tried to explain the management and the offshore teams, that this wasn't actually testing anything, they didn't really get it.
SilverScreen wrote: » I'm assuming that doMethod() is meant to return a String and that's what was meant to be tested. Otherwise it makes no sense at all
Aswerty wrote: » But returnValue is final when assigned to an empty string!! :pac: WTF?
GreeBo wrote: » I had someone tell me that they could delete a bunch of failing unit tests as "no one would notice and I'm sure no one knows what they do anyway" Should I mention that we are on a drive to improve test coverage? And that this person is on that team?
jester77 wrote: » hah, I came across that recently in a project. There was an initiative to get the builds green. Some took this to mean removing the failing tests :eek:
SilverScreen wrote: » Yeah that's another thing. They were more than likely using a static analysis tool like PMD. My assumption is to remove line 3 and change line 6 to String returnValue = objUnderTest.doMethod(); That's if doMethod() actually returns something...
var width = <%= Session["ScreenWidth"].ToString() %> - 970 - 1;
annacsnolan wrote: » Hi All, Sorry to butt in on the conversation. I am urgently looking for a tutor in HTML and CSS. I don't suppose any of you are in Cork city and willing to provide some evening/ weekend grinds? Thank you!
Lemming wrote: » And now .... try/catch blocks being used to govern program flow.
Lemming wrote: » Two in one day .... There was the method that's 5000+ lines long this morning. And now .... try/catch blocks being used to govern program flow./me heads desk.
BrokenArrows wrote: » Can you post an example of how he was using the try catch blocks. I can't image how that would work unless he was purposely causing exceptions.
double blah; try { blah = Convert.ToDouble(randomStringValue); } catch { blah = -1; }
Colonel Panic wrote: » That reeks of someone who comes from a procedural background. There are some times though when the .Net framework throws exceptions for stupid reasons. HttpWebRequest for example. Why throw an exception for 404s?
Colonel Panic wrote: » That reeks of someone who comes from a procedural background.
Berserker wrote: » What you would prefer it to do?
Lemming wrote: » I disagree. It reeks of someone who doesn't remember one of the first things you're told about try/catch blocks in uni; they are NOT execution control mechanisms. I remember that from being introduced to try/catch blocks in C back in the day in my second year of third level education. That's about fifteen years ago ...
Colonel Panic wrote: » try/catch blocks in C? As in SEH? That's quite a specific and not that useful thing to teach in 2nd year of 3rd level education.
Anesthetize wrote: » Came across something like this during the week: if (.....) { <some statement>; } else <some statement>; <some statement>; It really annoys me when people don't use brackets with if-else statements in Java. Just because you can doesn't mean you should.
yes there wrote: » Surely that is down to organisation conventions is it not. That's a personal gripe not a coding horror.
if (.....) { <some statement>; } else <some statement>; <some statement>;
oscarBravo wrote: » What makes it a true horror is what was lost by not using code tags on the original post:if (.....) { <some statement>; } else <some statement>; <some statement>; Now that's pure evil.
if (.....) <some statement>; else <some statement>; <some statement>;
oscarBravo wrote: » (It's at times like this I'm really glad I'm a Python guy...)