You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unit tests need to make sure they reset the state of singletons #103
I've come across this very subtle issue recently. I have found that running all tests in one bundle with "mvn install" can have a very different behaviour than running tests individually. Maven by default uses one single JVM to run the tests. Static variables like those used in singletons (e.g. AtomCache) are not necessarily reinitialise at the beginning of each test. Thus the tests have a different outcome when running in a bundle or running separately.
One workaround is always using this setting in the pom.xml:
For instance if one uses that, then 2 tests fail: TestBond and SiftsChainToUniprotMappingTest (easily reproducible by just running the tests individually).
For TestBond the issue seems to be a PDB parsing bug in entry 145D. Apparently when running tests in one bundle the flag setCreateAtomBonds was not set as expected and then the bug was not seen.
For SiftsChainToUniprotMappingTest the issue seems to be that the sifts file was not downloaded if run individually but it was if run in a bundle. Spencer proposed a fix for that, see this commit d6b64f7
Another weird behaviour was with TestAltLocs: in test3PIU(), the structure would sometimes be parsed from PDB file and sometimes from mmCIF (depending if run in bundle or individually). There seems to be a bug in mmCIF altLoc parsing (see #76 ) and thus sometimes it would fail and sometimes not. The patch in d6b64f7 demonstrates that.
I checked out the testsissue branch and fixed the SiftsChainToUniprotMappingTest. mvn clean install now works fine for me, however when I commit this to my fork on github andreasprlic@3b5f130 , travis still has some issues...
Jose is a power tester! Maybe sorting out these problems with static variables and cached files will make the travis builds more stable, as I feel like it often complains about things that work fine on my desktop.
So one important detail (it took me most of the day to figure it out!): the pom.xml patch above only works on surefire >2.14. So in andreasprlic@3b5f130 it is having no effect unless one changes the version to 2.14 or newer. Once you put that in, then both mvn install and mvn -Dtest=TestBond test fail for TestBond.test145D()
@josemduarte we should update to surefire 2.17 in any case, or the build won't work on jdk 8, which was released yesterday. I can do that in a separate pull request, if that would be better.
Activity
josemduarte commentedon Mar 18, 2014
Another weird behaviour was with
TestAltLocs: intest3PIU(), the structure would sometimes be parsed from PDB file and sometimes from mmCIF (depending if run in bundle or individually). There seems to be a bug in mmCIF altLoc parsing (see #76 ) and thus sometimes it would fail and sometimes not. The patch in d6b64f7 demonstrates that.andreasprlic commentedon Mar 18, 2014
thanks, well spotted!
andreasprlic commentedon Mar 18, 2014
I checked out the testsissue branch and fixed the SiftsChainToUniprotMappingTest. mvn clean install now works fine for me, however when I commit this to my fork on github andreasprlic@3b5f130 , travis still has some issues...
sbliven commentedon Mar 19, 2014
Jose is a power tester! Maybe sorting out these problems with static variables and cached files will make the travis builds more stable, as I feel like it often complains about things that work fine on my desktop.
josemduarte commentedon Mar 19, 2014
So one important detail (it took me most of the day to figure it out!): the pom.xml patch above only works on surefire >2.14. So in andreasprlic@3b5f130 it is having no effect unless one changes the version to 2.14 or newer. Once you put that in, then both
mvn installandmvn -Dtest=TestBond testfail forTestBond.test145D()heuermh commentedon Mar 19, 2014
@josemduarte we should update to surefire 2.17 in any case, or the build won't work on jdk 8, which was released yesterday. I can do that in a separate pull request, if that would be better.
heuermh commentedon Mar 19, 2014
I created pull request #104 for surefire 2.17 and
biojava/biojava-legacy#11
for the same for biojava-legacy.
andreasprlic commentedon Mar 19, 2014
I can reproduce the problem now, after upgrading to surefire 2.17.
fixing NPE with TestBonds biojava#103