r/javahelp • • Jun 29 '16

JUnit confusion

Here's the deal. I posted this on r/Java and got told to bring it here, so here goes. Started new project. Decided to try TDD and got JUnit set up in eclipse. Built some tests for functionality, then built code. Got a green bar, walked away and had a sandwich.

When I came back, on of the statements in the untouched code was recognized by the IDE as having an AssertionError, even though it built, ran, and the test passed less than an hour beforehand.

I have no cats, and unfortunately, I only have internet on my phone right now, so I can't share code. I've cleaned and re-built, to no avail.

Anyone else ever hear of something like this?

0 Upvotes

6 comments sorted by

4

u/nutrecht Lead Software Engineer / EU / 20+ YXP Jun 29 '16

Something has changed, you just don't know what did. Without any source that's all we can tell you.

1

u/[deleted] Jun 29 '16

Are you running concurrent code in your JUnits? Race conditions by definition can cause this to happen in untouched code.

1

u/AIMXFJ Jun 29 '16

Post some code please so we could help you

1

u/sadjava Jun 29 '16

Do you have autobuild on? How long is your auto save period? Almost sounds like either autobuild is off and you were testing with old class files, or if it's on, you didn't save so any changes weren't ran (I've totally never done that....).

1

u/b0147 Jun 29 '16

An other possible reason is that you are loading a file and you moved the file to "clean up" before your sandwich and the refering URL is now wrong

1

u/OffbeatDrizzle Jul 02 '16

Did you even look at why the assertion was failing? That would probably give you a big hint