This content has been marked as final.
Show 8 replies
-
1. Re: Testing SEAM Application with TestNG
dhinojosa Sep 8, 2008 9:43 PM (in response to vkommini)1. Depends on the level of testing, for integration testing that seems like it would work.
2. Without code it is harder to help. -
2. Re: Testing SEAM Application with TestNG
vkommini Sep 8, 2008 9:56 PM (in response to vkommini)Thank you Daniel. Here with I am sending code for the following files.
1. LoginTest.java
2. testing.xml
3. Ant Build.xml
1. LoginTest.java
package com.test;
//import com.beust.testng.annotations.*;
import org.apache.commons.lang.*;
import org.jboss.seam.mock.BaseSeamTest.ComponentTest;
import org.jboss.seam.mock.SeamTest;
import static org.jboss.seam.ScopeType.CONVERSATION;
import org.jboss.seam.core.Manager;
import org.jboss.seam.web.Session;
import org.jboss.seam.mock.SeamTest;
import org.testng.annotations.Test;
/**
* Tests StringUtils
*/
public class LoginTest extends SeamTest
{
@Test
public void isEmpty()
{
System.out.println("-- isEmpty ---");
assert StringUtils.isBlank(null);
assert StringUtils.isBlank("");
}
@Test
public void trim()
{
System.out.println("-- trim ---");
assert "foo".equals(StringUtils.trim(" foo "));
}
@Test
public void testSearch() throws Exception
{
new FacesRequest()
{
@Override
protected void updateModelValues() throws Exception
{
setValue("#{identity.username}", "site2test");
setValue("#{identity.password}", "test2day");
}
@Override
protected void invokeApplication()
{
assert invokeMethod("#{identity.login}").equals("success");
}
}.run();
}
@Test
public void testLogin() throws Exception
{
System.out.println("-- testLogin 1 ---");
new ComponentTest()
{
@Override
public void testComponents() throws Exception
{
System.out.println("-- testLogin 2 ---");
//assert getValue("#{identity.loggedIn}").equals(false);
System.out.println("-- testLogin 3 ---");
setValue("#{identity.username}", "site2test");
System.out.println("-- testLogin 4 ---");
setValue("#{identity.password}", "test2day");
setValue("#{identity.destination}", "BALANCES");
invokeMethod("#{identity.login}");
assert getValue("#{user.firstName}").equals("site2test");
}
}.run();
}
}
------------------------------------------------------- -
3. Re: Testing SEAM Application with TestNG
vkommini Sep 8, 2008 9:58 PM (in response to vkommini)Thank you Daniel. Here with I am sending code for the following files.
1. LoginTest.java
2. testing.xml
3. Ant Build.xml
1. LoginTest.java
package com.test;
//import com.beust.testng.annotations.*;
import org.apache.commons.lang.*;
import org.jboss.seam.mock.BaseSeamTest.ComponentTest;
import org.jboss.seam.mock.SeamTest;
import static org.jboss.seam.ScopeType.CONVERSATION;
import org.jboss.seam.core.Manager;
import org.jboss.seam.web.Session;
import org.jboss.seam.mock.SeamTest;
import org.testng.annotations.Test;
/**
* Tests StringUtils
*/
public class LoginTest extends SeamTest
{
@Test
public void isEmpty()
{
System.out.println("-- isEmpty ---");
assert StringUtils.isBlank(null);
assert StringUtils.isBlank("");
}
@Test
public void trim()
{
System.out.println("-- trim ---");
assert "foo".equals(StringUtils.trim(" foo "));
}
@Test
public void testSearch() throws Exception
{
new FacesRequest()
{
@Override
protected void updateModelValues() throws Exception
{
setValue("#{identity.username}", "site2test");
setValue("#{identity.password}", "test2day");
}
@Override
protected void invokeApplication()
{
assert invokeMethod("#{identity.login}").equals("success");
}
}.run();
}
@Test
public void testLogin() throws Exception
{
System.out.println("-- testLogin 1 ---");
new ComponentTest()
{
@Override
public void testComponents() throws Exception
{
System.out.println("-- testLogin 2 ---");
//assert getValue("#{identity.loggedIn}").equals(false);
System.out.println("-- testLogin 3 ---");
setValue("#{identity.username}", "site2test");
System.out.println("-- testLogin 4 ---");
setValue("#{identity.password}", "test2day");
setValue("#{identity.destination}", "BALANCES");
invokeMethod("#{identity.login}");
assert getValue("#{user.firstName}").equals("site2test");
}
}.run();
}
}
-------------------------------------------------------
2. testing.xml
<!DOCTYPE suite SYSTEM "http://beust.com/testng/testng-1.0.dtd" >
<suite name="Test Suite">
<test name="TestNG Basic Tests">
<classes>
<class name="com.test.LoginTest" />
</classes>
</test>
</suite>
------------------------------------------------------------
3. Ant Build.xml
<project name="TestNG BAISI Application" default="test" basedir=".">
<property name="src.dir" value="src" />
<property name="test-output.dir" value="test-output" />
<!-- Set Classpath -->
<fileset id="lib" dir="./lib">
<include name="*.jar" />
</fileset>
<path id="build.classpath">
<fileset refid="lib" />
</path>
<!-- Compile the Source code -->
<target name="compile">
<echo message="compiling tests"/>
<mkdir dir="classes"/>
<javac debug="true" source="1.5"
classpathref="build.classpath"
srcdir="src"
destdir="classes"/>
</target>
<!-- Run the TestNG Test cases -->
<!--
<taskdef name="testng"
classname="com.beust.testng.TestNGAntTask"
classpathref="build.classpath"/>
<path id="runpath">
<path refid="build.classpath"/>
<pathelement location="classes"/>
</path>
<target name="test" depends="compile">
<echo message="running tests"/>
<testng fork="yes" classpathref="runpath" outputDir="test-output">
<fileset dir="src" includes="testng.xml"/>
<jvmarg value="-ea" />
</testng>
</target>
-->
<taskdef name="testng"
classname="org.testng.TestNGAntTask"
classpathref="build.classpath"/>
<path id="runpath">
<path refid="build.classpath"/>
<pathelement location="classes"/>
</path>
<target name="test" depends="compile">
<echo message="running tests"/>
<taskdef resource="testngtasks" classpathref="build.classpath" />
<testng sourceDir="${src.dir}" outputdir="${test-output.dir}" classpathref="runpath">
<xmlfileset dir="${src.dir}" includes="*.xml" />
</testng>
</target>
</project>
-------------------------------------------------------
Thank you,
VK -
4. Re: Testing SEAM Application with TestNG
jnusaira Sep 8, 2008 11:00 PM (in response to vkommini)Maybe daniel can help you more, but i am having a difficult time understanding your question.
The test you have right there is an integration test using the jboss embedded in the background.
Is that not passing? Or are you asking if you shouldn't use it? What exactly are you trying to test?
-
5. Re: Testing SEAM Application with TestNG
vkommini Sep 8, 2008 11:09 PM (in response to vkommini)Hi Joseph,
I am not running any JBoss Embedded in background.
I have four methods in LoginTest.java. When I invoke testing.xml, it should call (run) those four methods. But when I run the ant build.xml, I get the below message in the console.
Buildfile: C:\TestNG BAISI Application\build_test.xml
compile:
[echo] compiling tests
test:
[echo] running tests
[testng] [Parser] Running:
[testng] C:\TestNG BAISI Application\src\testng.xml
[testng] ===============================================
[testng] Test Suite
[testng] Total tests run: 0, Failures: 0, Skips: 0
[testng] ===============================================
BUILD SUCCESSFUL
Hope it is clear, please let me know, if you need any further info.
Thank you,
VK -
6. Re: Testing SEAM Application with TestNG
dhinojosa Sep 9, 2008 4:49 AM (in response to vkommini)Looks like something is wrong with your build script...
It is looking at C:\TestNG BAISI Application\src\testng.xml still instead of testing.xml (note the i). Isn't testing.xml the file that should be processing? -
7. Re: Testing SEAM Application with TestNG
vkommini Sep 9, 2008 2:28 PM (in response to vkommini)Daniel,
you are correct. it was my typo mistake. I have created a file as testng.xml. since I have used *.xml in ant script, it pickup testng.xml to run.
infact I renamed testng.xml to testing.xml and ran the Ant Script, still I am getting same issue.
Buildfile: C:\BofA\TestNG BAISI Application\build_test.xml
compile:
[echo] compiling tests
test:
[echo] running tests
[testng] [Parser] Running:
[testng] C:\BofA\TestNG BAISI Application\src\testing.xml
[testng] ===============================================
[testng] BOA Suite
[testng] Total tests run: 0, Failures: 0, Skips: 0
[testng] ===============================================
BUILD SUCCESSFUL
Total time: 1 second
-----------------------------
Thank you,
VK -
8. Re: Testing SEAM Application with TestNG
dhinojosa Sep 10, 2008 8:03 AM (in response to vkommini)Well, there is still not much information for me to help without getting my hands on it.
So, let me post some items for you to look out for- Classpath is incorrect or is in the incorrect order
- Your test class files cannot be found
Another question, are you using seam-gen's build.xml? or your own build.xml?