简体   繁体   中英

How do I open a new project and perspective in SWTBot plug-in test?

For example: I want to "test" Eclipse-CDT. I can't do it using Java code so I need to import a C-project. I didn't found it in Run Configurtion therefore I:
* Create SWTBot Test Plug-in
* Record a sequence of actions via SWTBot Test Recorder:
** Import a C-project
** Change perspective
** Do stuff (run program and check registers for exapmles)
* Insert recorded actions into @Test method
* Run As > SWTBot Test
Here is a problem. SWTBot fails at picking imported project showing various changing errors (mostly "WidgetNotFoundException" at expanding package view or picking imported project from project tree and "NullPointerException" at the same point). Testing code looks like

@Test
public void test() {
  bot.menu("File").menu("Import...").click();
  bot.tree().expandNode("General").getNode("Existing Projects into Workspace").select();  
  bot.button("Next >").click();
  bot.comboBox().setText("C:\\Sandbox\\JavaWorkspace\\CDTtest");
  bot.button("Browse...").click();
  bot.button("Finish").click();
  bot.toolbarButtonWithTooltip("&Restore").click();
  bot.tree().getTreeItem("CDTtest").getNode("main.c").select();
  bot.menu("Project").menu("Build Project").click();
  bot.menu("Run").menu("Debug").click();
  bot.tree().getTreeItem("General Registers").expand();
  bot.menu("Run").menu("Step Over").click();
}

Is there more appropriate way to described things? Or maybe a more appropriate tool for that?

It seems like the generated code doesn't include anything about switching to another property. It's possible that there is no recording rule existing for this action. You may need to tweak your test manually to add this missing operation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM