Hi all.
I’m having an issue when writing tests.
I need some assets to be able to run my tests. In the setup
method,
i copy an assets
directory in my test project and then move my test file inside this directory.
But when doing so (moving the file), the ide seems to prerform refactoring even though it completely breaks my tests.
This is the file before
<screens xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://ofbiz.apache.org/Widget-Screen"
xsi:schemaLocation="http://ofbiz.apache.org/Widget-Screen http://ofbiz.apache.org/dtds/widget-screen.xsd">
<screen name="Foo">
<section>
<widgets>
<include-screen name="DuplicatedTargetScreen" location="component://zelda/widget/DuplicatedTargetScreens.xml"/>
</widgets>
</section>
</screen>
</screens>
This is the test code
void testDuplicatedTargetScreen() {
String desc = message('inspection.screen.duplicate.display.descriptor')
myFixture.enableInspections(new DuplicatedScreenInspection())
String file = "${this.getTestName(false)}.xml"
String dest = 'zelda/widget'
myFixture.moveFile("xml/$file", dest)
myFixture.configureByFile("$dest/$file")
doHighlight(true, desc)
}
protected void doHighlight(boolean mustFind, String desc) {
List<HighlightInfo> highlightInfos = myFixture.doHighlighting()
List<String> highlightDescs = highlightInfos.collect { it.description }
if (!mustFind) {
assert !highlightDescs.contains(desc)
} else {
assertFalse highlightInfos.isEmpty()
assert highlightDescs.contains(desc)
}
}
And this is the test file after (I used debug to get the file content)
<screens xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://ofbiz.apache.org/Widget-Screen"
xsi:schemaLocation="http://ofbiz.apache.org/Widget-Screen http://ofbiz.apache.org/dtds/widget-screen.xsd">
<screen name="Foo">
<section>
<widgets>
<include-screen name="DuplicatedTargetScreen" location="../../elden/widget/EldenScreens.xml"/>
</widgets>
</section>
</screen>
</screens>
Notice the location
attribute value that has been modified.
Is there a way to prevent refactoring in tests while moving files ? It kinda kills the tests
Thanks