Question regarding TestNgGuiceBerry.setUp

31 views
Skip to first unread message

prabu

unread,
Sep 28, 2010, 9:30:34 AM9/28/10
to guiceberry-users
package com.jcatalog.pim;

import static org.testng.AssertJUnit.*;
import com.google.common.testing.TearDown;
import com.google.guiceberry.testng.TestNgGuiceBerry;
import com.google.inject.Inject;
import com.catalog.pim.ServerEnv;
import com.thoughtworks.selenium.Selenium;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.ITestResult;
import org.testng.Reporter;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

import java.lang.reflect.Method;


public class TestCreateCustomer {





private TearDown toTearDown;

@BeforeMethod
public void setUp(Method m) {
// Make this the call to TestNgGuiceBerry.setUp as early as
possible
toTearDown = TestNgGuiceBerry.setUp(this, m, ServerEnv.class);
}


@Inject
private ProjectBasedKeywords proj;



@Test
public void createCustomer(){
// Getting generic keywords object
String result = "PASS";
//logger.debug(" Entering createcustomer {}",result);
//ITestResult
GenericKeywords generic = proj.getGeneric();
generic.open("/");
proj.clickApplication("PIM");
proj.login("jca","jcadmin");

System.out.println(" Do something after the failure");

}





}


Please look at the the class. It seems like setUp() is called before
each test method. that means it calls ServerEnv object and does the
binding ..and things like that? Dont you think it is unnecessary to do
this?


Luiz-Otavio Zorzella

unread,
Sep 28, 2010, 2:26:40 PM9/28/10
to guiceber...@googlegroups.com
setUp should be called before every test. After the first time,
GuiceBerry will figure out it has already created the injector for
that GBEnv, and it will use it to inject the test.

Z

> --
> You received this message because you are subscribed to the Google Groups "guiceberry-users" group.
> To post to this group, send email to guiceber...@googlegroups.com.
> To unsubscribe from this group, send email to guiceberry-use...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/guiceberry-users?hl=en.
>
>

Reply all
Reply to author
Forward
0 new messages