forked from eclipse-archived/reddeer
-
Notifications
You must be signed in to change notification settings - Fork 1
Write you own RedDeer API for your tests
jbdevstudioqajenkins edited this page May 21, 2015
·
9 revisions
Once you start using RedDeer in your tests you find out that would be good to create similar level of abstraction also for your own tested UI Parts. Starting with that is simple and it usually contains just few steps:
- create new eclipse plugin for your eclipse API
- write new View, Editor or Shell Implementation by extending appropriate RedDeer implementations or abstract classes.
- set exports and all needed things in you MANIFEST.MF
- start using your API in your test plugin along with RedDeer API
- if this API covers some specific Eclipse features that are not covered by RedDeer you can also create an issue and provide you code as a pull request to be part of next version of RedDeer.
Here I show you hypothetical example for your API that consists of Login Shell of your product
package org.jboss.reddeer.snippet.test.example;
import org.jboss.reddeer.common.wait.WaitWhile;
import org.jboss.reddeer.core.condition.ShellWithTextIsActive;
import org.jboss.reddeer.swt.api.Button;
import org.jboss.reddeer.swt.api.Text;
import org.jboss.reddeer.swt.impl.button.PushButton;
import org.jboss.reddeer.swt.impl.shell.DefaultShell;
import org.jboss.reddeer.swt.impl.text.DefaultText;
public class LoginShell {
public static final String SHELL_TITLE = "Credentials";
public LoginShell() {
new DefaultShell(SHELL_TITLE);
}
public void setUsername(String username) {
Text usernameText = new DefaultText("Username:");
usernameText.setText(username);
}
public void setPassword(String password) {
Text passwordText = new DefaultText("Password:");
passwordText.setText(password);
}
public void login() {
Button loginButton = new PushButton("Login");
loginButton.click();
new WaitWhile(new ShellWithTextIsActive(SHELL_TITLE));
}
}Here is how you can use it in your tests let's say com.myeclipseproduct.redder.usermodule.test
package org.jboss.reddeer.snippet.test;
import org.jboss.reddeer.snippet.test.example.LoginShell;
import org.jboss.reddeer.swt.api.Menu;
import org.jboss.reddeer.swt.impl.menu.ShellMenu;
import org.jboss.reddeer.workbench.impl.shell.WorkbenchShell;
import org.junit.Test;
public class LoginShellTest {
@Test
public void testMyLoginShell() {
new WorkbenchShell();
Menu shellMenu = new ShellMenu("MyEclipseProduct","Login to My Eclipse product");
shellMenu.select();
// Your own RedDeer API usage
LoginShell shell = new LoginShell();
shell.setUsername("tester");
shell.setPassword("secret");
shell.login();
}
}You can add some assertion and other code that check the condition but essentially this would test your code and provide re-usability for you test and also for other test components that would need to work with this Login Shell.
JBoss Red Deer - Quick Links
- Home
- [Release notes] (/jboss-reddeer/reddeer/wiki/Release-notes)
- Articles
- JavaDoc
- User guide
- Contributor Guide
- FAQ