java - How to use FEST tests with Groovy's GMock framework -
i'm trying use fest swing test suite write test different interface responses. in single class situations works well. however, have situation have using gmocktestcase. set mocked method calls returns , create "play" enclosure, asserts fail. if run same test without mocked class test passes. there order in things must set up?
here test:
@test void testsshouldreturnradiobuttonselectedfromclassgroupbuttongroupkeypressed(){ def mockclassmap = getclassmap() mockpg.getavailibleclass().returns(mockclassmap) panel.plygen = mockpg panel.racevalue = 1 panel.gendervalue = 2 panel.gpane.mainm.setvisible(false) panel.gpane.createplayerstats.setvisible(true) //panel.plygen = new playergenerater() play{ festsetup(panel.gpane.chooseclass) panel.gpane.rerolldice.requestfocusinwindow() // simulate key stroke change panel view robot.keypress(vk_a) robot.keyrelease(vk_a) // simulate key stroke select radio button option robot.keypress(vk_m) robot.keyrelease(vk_m) assertthat(panel.classvalue, is(3)) } }
any appreciated.
just answer own question benefit of might have similar question. answer limit test single user input interaction. above trying simulate 2 things. interaction move 1 panel screen second interaction on second panel. limiting interaction test second half of user interaction allowed fest recognize interactions. resulting code passing test in example was:
def mockclassmap = getclassmap() panel.plygen = mockpg mockpg.getavailableclass().returns(mockclassmap) panel.racevalue = 1 panel.gendervalue = 2 panel.gpane.mainm.setvisible(false) panel.gpane.chooseclass.setvisible(true) //panel.plygen = new playergenerator() play{ festsetup(panel.gpane.chooseclass) /*additional methods need triggered in order *set panel actual test */ panel.setclassgroup() gpane.classgrouppanel.revalidate() gpane.chooseclass.setvisible(true) //simulate user interaction robot.keypress(vk_m) robot.keyrelease(vk_m) //assert results assertthat gpane.selectclass.getselection(), is(gpane.monk.getmodel()) }
so basic unit testing 101 isolate tests single actions
Comments
Post a Comment