[
https://issues.jboss.org/browse/ARQ-1340?page=com.atlassian.jira.plugin.s...
]
Alex Okrushko commented on ARQ-1340:
------------------------------------
Lukáš Fryč, Karel Piwko, thanks guys for the quick response on the issue.
In regards with "anti-pattern", I had a similar discussion
[
here|http://stackoverflow.com/questions/12411431/pytest-how-to-skip-the-r...]
when I was creating my test framework in Python.
The main point is that WebDriver tests are not "Unit-Test-like", they are
"Functional tests".
I got the framework running in the following pattern, which (ideally) I'm trying to
use in Java:
- Each *Class* is a *Test Case*
- Each *@Test* is a *Test Step*
- *@BeforeClass* is the *Prerequisites*
with the following logic is in effect:
# All the "Test Steps" within a "Class" are executed @InSequence
# In Class if the "Test Step" *{color:red}Fails{color}* -> the other
"test steps" are not run and are marked as *{color:gold}Skipped{color}* (since
that would be a *false positive*)
# *Finalizer* object is launched in @AfterClass and executes the "cleanup" to
get the web-app to the initial state:
#- If the "Test Step" modifies the "State" of the web-app, then it
should "add" extra "cleanup" to the *Finalizer* (just in case if the
next "Test Step" fails)
With those rules in mind here is the simple "Test Case": _"Username of the
existing User can be changed"_.
the structure that I have in mind (and that was successfully implemented in Python):
{code:java}
Class TestUserNameCanBeChanged{
@Drone
WebDriver driver;
@Page
Login login;
@Page
Main main;
@BeforeClass
void setup(){
//Prerequisites:
//navigate to the login page
driver.navigate().to(login.URL);
//login
login.login(Username, Password);
//create user
main.createUser(NewUserName);
//add to remove the user at the end
finalizer.add(main.deleteUser, NewUserName);
}
@Test
@InSequence(1)
void testChangeName(){
//navigate to "edit" username
main.user_profile.edit();
//change the name
main.user.username = "Edited User Name";
//verify that the name was changed
Assert.assertTrue(main.user.getName().equals("Edited User Name"));
//remove cleanup function for NewUserName and replace it with cleanup for
"Edited User Name"
finalizer.remove(main.deleteUser, NewUserName);
finalizer.add(main.deleteUser, "Edited User Name");
}
@Test
@InSequence(2)
void testSomeOtherTestRelatedToEditedName(){
//verify some other places where the newly edited username appears
}
@AfterClass
void cleanup(){
//Get the web-app to the initial state (e.g. execute the chain of
"cleanup" that Finalizer has collected and logout)
finalizer.execute();
main.logout();
}
}
{code}
This is just a quick example that I got out of my head, hope you see the idea.
I might be wrong and Java has other implementation that are well-used/recognized in
Selenium Web-Testing then I would appreciate if you can point me in the right direction :)
Drone webdriver is not created during @BeforeClass
--------------------------------------------------
Key: ARQ-1340
URL:
https://issues.jboss.org/browse/ARQ-1340
Project: Arquillian
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: Extension - Drone
Affects Versions: drone_1.1.1.Final
Environment: Arquillian JUnit Container 1.0.3.Final
Arquillian Graphene Webdriver 2.0.0.Alpha3
Arquillian Drone dependencies and Selenium dependencies 1.1.1.Final
Arquillian Core dependencies 1.0.3.Final
junit 4.8.1
jdk 1.6
Reporter: Alex Okrushko
Assignee: Karel Piwko
Drone webdriver is not created during @BeforeClass, however *is created during @Before or
if called by GrapheneContext.getProxy()*
The following does NOT work:
{code:java}
@RunWith(Arquillian.class)
public class TestDroneLogin {
@Drone
private static WebDriver driver;
@BeforeClass
public static void setup(){
//GrapheneContext.getProxy().navigate().to("http://google.com");
driver.navigate().to("http://google.com");
}
@Test
public void testInput(){
driver.findElement(By.cssSelector("input#gbqfq"));
}
}
{code}
However, if I use {{GrapheneContext.getProxy()}} instead of {{driver}}, everything works
as expected:
{code:java}
@BeforeClass
public static void setup(){
GrapheneContext.getProxy().navigate().to("http://google.com");
}
{code}
ALSO, if {{@Before}} is used then Drone webdriver is created as expected, so this problem
is specific to {{@BeforeClass}}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:
http://www.atlassian.com/software/jira