Let me give you a concrete example of how this will make testing very easy
in our products.
Before running any tests, we need to extract the binaries, copy artifacts,
then start the Carbon servers. Next we need the tests to run and finally
shutdown the servers. This is very difficult to do with JUnit in a
straightforward manner. This is the reason why different product teams have
incorporated various hacks to do this. With TestNG it is very simple.
We will have a StartupUtil as follows;
public class StartupUtil {
*@BeforeGroups*(value = {"*appserver*", "*esb*"})
public void startup(){
extractBinaries();
copyArtifacts();
startServers();
}
@*AfterGroups*(value = "*appserver*", "*esb*")
public void shutdown(){
stopServers();
}
}
Our test classes will look like the following.
public class TestNGSimpleTest {
int testInt;
@BeforeSuite
public void beforeSuite(){
System.out.println("Before suite");
}
@AfterSuite
public void afterSuite(){
System.out.println("After suite");
}
@BeforeMethod
public void setUp() {
testInt = 0;
System.out.println("=========>" +
System.getProperty("sec.verifier.dir"));
}
@AfterMethod
public void tearDown() {
testInt = 0;
System.out.println("=========>" +
System.getProperty("sec.verifier.dir"));
}
@Test(groups = {"*appserver*"})
public void addTest() {
testInt++;
assert testInt == 1;
System.out.println("add test");
}
@Test(groups = {"*appserver*"})
public void subtractTest() {
testInt--;
assert testInt == -1;
System.out.println("subtract test");
}
}
Take note of the groups concepts & BeforeGroups/AfterGroups annotations. We
may need a week's worth of effort to migrate all our tests but it will be
well worth the effort.
If there are no objections, I can start implementing this for
carbon/core/integration.
On Tue, Dec 13, 2011 at 7:56 PM, Afkham Azeez <[email protected]> wrote:
> Folks,
> I was playing around a bit with TestNG (
> http://testng.org/doc/documentation-main.html#introduction) & it seems to
> be the way to go for the type of integration testing we are doing. This may
> involve major changes at the platform testing level but will be worth the
> investment.
>
> Here are some articles that compare TestNG with JUnit4. We are using JUnit
> 3.
>
> http://www.mkyong.com/unittest/junit-4-vs-testng-comparison/
> http://nelz.net/2010/10/06/testng-vs-junit4/
>
> I had a chat with Krishantha & he too agrees that TestNG is more suitable
> for the type of test automation we do. Does anybody have any concerns
> regarding this move?
>
> --
> *Afkham Azeez*
> Director of Architecture; WSO2, Inc.; http://wso2.com
> Member; Apache Software Foundation; http://www.apache.org/
> * <http://www.apache.org/>**
> email: **[email protected]* <[email protected]>* cell: +94 77 3320919
> blog: **http://blog.afkham.org* <http://blog.afkham.org>*
> twitter: **http://twitter.com/afkham_azeez*<http://twitter.com/afkham_azeez>
> *
> linked-in: **http://lk.linkedin.com/in/afkhamazeez*
> *
> *
> *Lean . Enterprise . Middleware*
>
>
--
*Afkham Azeez*
Director of Architecture; WSO2, Inc.; http://wso2.com
Member; Apache Software Foundation; http://www.apache.org/
* <http://www.apache.org/>**
email: **[email protected]* <[email protected]>* cell: +94 77 3320919
blog: **http://blog.afkham.org* <http://blog.afkham.org>*
twitter: **http://twitter.com/afkham_azeez*<http://twitter.com/afkham_azeez>
*
linked-in: **http://lk.linkedin.com/in/afkhamazeez*
*
*
*Lean . Enterprise . Middleware*
_______________________________________________
Carbon-dev mailing list
[email protected]
http://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev