I have a Java program that when run, displays a GUI with a button to import a file. I want to write a unit test for the import file method to make sure the method executes all the way through, but that method is only called when the button is pressed which is by extension only available when the program is run manually. What's the best approach for something like this?
Method to test:
public FileClass{
public Boolean import(someVar1, someVar2, someVar3){
Boolean success = false;
......
click some buttons, choose the file, and click OK
......
return success;
}
}
My junit test:
public class FileClassTest{
@Test
public void importTest(){
....
....
assertTrue(FileClass.import(x,y,z));
}
}