- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我目前正在尝试使用 Arquillian 和 TestNG 进行 JSFUnit-Test,但 JSFServerSession 和 JSFClientSession-object 为 NULL。有 JSFUnit 和 TestNG 的工作示例吗?还是这里有其他问题?
我的测试类:
package my.beautiful.tests;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import javax.faces.component.UIComponent;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.arquillian.testng.Arquillian;
import org.jboss.jsfunit.api.InitialPage;
import org.jboss.jsfunit.jsfsession.JSFClientSession;
import org.jboss.jsfunit.jsfsession.JSFServerSession;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.testng.AssertJUnit;
import org.testng.annotations.Test;
public class JSFUnitTestExample /* Arquillian needs this, not TestNG */extends Arquillian {
@ArquillianResource URL context;
@Deployment
public static WebArchive createDeployment() {
return ShrinkWrap.create( WebArchive.class, "jsfunit_test.war" ).addClass( JSFUnitBean.class )
.addAsWebInfResource( new File( "src/main/webapp/WEB-INF", "faces-config.xml" ), "faces-config.xml" )
.addAsWebInfResource( new File( "src/main/webapp/WEB-INF", "beans.xml" ), "beans.xml" )
.setWebXML( new File( "src/main/webapp/WEB-INF", "web.xml" ) )
.addAsWebResource( new File( "src/main/webapp", "index.xhtml" ) );
}
@Test(dataProvider = Arquillian.ARQUILLIAN_DATA_PROVIDER, description = "Testet, ob bei dem Klick auf den Button der Text 'Hello World' erscheint und das Bean somit richtig angesprochen wird.")
@InitialPage("/index.xhtml")
public void testInitialPage( JSFServerSession server, JSFClientSession client ) throws IOException {
AssertJUnit.assertNotNull( server );
AssertJUnit.assertNotNull( client );
AssertJUnit.assertEquals( "/index.xhtml", server.getCurrentViewID() );
client.click( "submitButton" );
UIComponent result = server.findComponent( "result" );
AssertJUnit.assertTrue( result.isRendered() );
AssertJUnit.assertEquals( "Hello World", server.getManagedBeanValue( "#{jSFUnitBean.message}" ) );
AssertJUnit.assertEquals( "/index.xhtml", server.getCurrentViewID() );
}
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>my.beautiful.tests</groupId>
<artifactId>jsfunit-example</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<name>Tests :: JSFUnit-Tests with Arquillian</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<arquillian.debug>true</arquillian.debug> <!-- tells arquillian to be verbose -->
<openejb.arquillian.debug>true</openejb.arquillian.debug> <!-- tells arquillian to be verbose -->
<!-- versions -->
<tomee.version>1.5.1</tomee.version>
<arquillian.version>1.0.2.Final</arquillian.version>
<myfaced.version>2.1.8</myfaced.version>
<jsfunit.version>2.0.0.Beta2</jsfunit.version>
</properties>
<build>
<finalName>jsfunit_test</finalName>
<plugins>
<!-- its Java 7 (1.7) -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<!-- /its Java 7 (1.7) -->
<!-- <special options for TESTING> -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
<configuration>
<includes>
<include>**/*.java</include><!-- dont just run *Test.java-files, which is default for surefire -->
</includes>
<!-- for Arquillian -->
<parallel>none</parallel> <!-- for NOT spawning servers with the same port/port-colision -->
<threadCount>1</threadCount> <!-- for NOT spawning servers with the same port/port-colision -->
<systemPropertyVariables>
<arquillian.launch>tomee-embedded</arquillian.launch>
</systemPropertyVariables>
<!-- /for Arquillian -->
</configuration>
</plugin>
<!-- </special options for TESTING> -->
<!-- <for having better IDE-Support> -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</configuration>
</plugin>
<!-- </for having better IDE-Support> -->
</plugins>
</build>
<dependencies>
<!-- javaEE (tomEE) -->
<dependency>
<groupId>org.apache.openejb</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0-4</version>
<scope>provided</scope>
</dependency>
<!-- /javaEE (tomEE) -->
<!-- javax.faces -->
<dependency>
<groupId>org.apache.myfaces.core</groupId>
<artifactId>myfaces-api</artifactId>
<version>2.1.8</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.myfaces.core</groupId>
<artifactId>myfaces-impl</artifactId>
<version>2.1.8</version>
<scope>provided</scope>
</dependency>
<!-- /javax.faces -->
<!-- jsfunit -->
<dependency>
<groupId>org.jboss.jsfunit</groupId>
<artifactId>jboss-jsfunit-core</artifactId>
<version>2.0.0.Beta2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jboss.jsfunit</groupId>
<artifactId>jsfunit-arquillian</artifactId>
<version>2.0.0.Beta2</version>
<scope>test</scope>
</dependency>
<!-- /jsfunit -->
<!-- Arquilian -->
<dependency>
<groupId>org.jboss.arquillian.testng</groupId>
<artifactId>arquillian-testng-container</artifactId><!-- if JUnit is used, change this container to corresponding one -->
<version>1.0.2.Final</version>
<scope>test</scope>
</dependency>
<!-- Arquilian Adapter -->
<dependency>
<groupId>org.apache.openejb</groupId>
<artifactId>arquillian-tomee-embedded</artifactId>
<version>1.5.1</version>
<scope>test</scope>
</dependency>
<!-- /Arquilian Adapter -->
<!-- ShrinkWrap - Dependency for Arquillian -->
<dependency>
<groupId>org.jboss.shrinkwrap</groupId>
<artifactId>shrinkwrap-api</artifactId>
<version>1.1.1-alpha-2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-api-maven</artifactId>
<version>2.0.0-alpha-6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-impl-maven</artifactId>
<version>2.0.0-alpha-6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap.descriptors</groupId>
<artifactId>shrinkwrap-descriptors-impl</artifactId>
<version>1.1.0-beta-1</version>
<scope>test</scope>
</dependency>
<!-- /ShrinkWrap - Dependency for Arquillian -->
<!-- /Arquilian -->
<!-- TestNG -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8</version>
<scope>test</scope>
</dependency>
<!-- /TestNG -->
</dependencies>
<repositories>
<!-- jsfunit -->
<repository>
<id>JBoss Dev</id>
<url>http://repository.jboss.org/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</repository>
<!-- /jsfunit -->
<repository>
<id>apache-m2-snapshot</id>
<name>Apache Snapshot Repository</name>
<url>http://repository.apache.org/snapshots</url>
</repository>
</repositories>
</project>
InitialPage (null, null)
"java.lang.AssertionError: at my.beatiful.tests.JSFUnitTestExample.testInitialPage(JSFUnitTestExample.java:35) at org.jboss.arquillian.testng.Arquillian$2.invoke(Arquillian.java:167) at org.jboss.arquillian.container.test.impl.execution.LocalTestExecuter.execute(LocalTestExecuter.java:60) at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94) at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99) at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81) at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135) at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115) at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67) at org.jboss.arquillian.container.test.impl.client.protocol.local.LocalContainerMethodExecutor.invoke(LocalContainerMethodExecutor.java:50) at org.jboss.arquillian.container.test.impl.execution.RemoteTestExecuter.execute(RemoteTestExecuter.java:120) at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94) at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99) at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81) at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135) at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115) at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67) at org.jboss.arquillian.container.test.impl.execution.ClientTestExecuter.execute(ClientTestExecuter.java:57) at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94) at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99) at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81) at org.jboss.arquillian.container.test.impl.client.ContainerEventController.createContext(ContainerEventController.java:142) at org.jboss.arquillian.container.test.impl.client.ContainerEventController.createTestContext(ContainerEventController.java:129) at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94) at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88) at org.jboss.arquillian.test.impl.TestContextHandler.createTestContext(TestContextHandler.java:89) at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94) at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88) at org.jboss.arquillian.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:75) at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94) at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88) at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:60) at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94) at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88) at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135) at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.test(EventTestRunnerAdaptor.java:111) at org.jboss.arquillian.testng.Arquillian.run(Arquillian.java:158) at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:77) at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:110) at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:106) at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189) at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165) at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85) at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75) ... Removed 63 stack frames
java.lang.AssertionError: at org.testng.AssertJUnit.fail(AssertJUnit.java:59) at org.testng.AssertJUnit.assertTrue(AssertJUnit.java:24) at org.testng.AssertJUnit.assertNotNull(AssertJUnit.java:267) at org.testng.AssertJUnit.assertNotNull(AssertJUnit.java:259) at my.beatiful.tests.JSFUnitTestExample.testInitialPage(JSFUnitTestExample.java:35) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80) at org.testng.internal.MethodInvocationHelper$1.runTestMethod(MethodInvocationHelper.java:182) at org.jboss.arquillian.testng.Arquillian$2.invoke(Arquillian.java:167) at org.jboss.arquillian.container.test.impl.execution.LocalTestExecuter.execute(LocalTestExecuter.java:60) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94) at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99) at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81) at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135) at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115) at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67) at org.jboss.arquillian.container.test.impl.client.protocol.local.LocalContainerMethodExecutor.invoke(LocalContainerMethodExecutor.java:50) at org.jboss.arquillian.container.test.impl.execution.RemoteTestExecuter.execute(RemoteTestExecuter.java:120) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94) at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99) at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81) at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135) at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115) at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67) at org.jboss.arquillian.container.test.impl.execution.ClientTestExecuter.execute(ClientTestExecuter.java:57) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94) at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99) at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81) at org.jboss.arquillian.container.test.impl.client.ContainerEventController.createContext(ContainerEventController.java:142) at org.jboss.arquillian.container.test.impl.client.ContainerEventController.createTestContext(ContainerEventController.java:129) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94) at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88) at org.jboss.arquillian.test.impl.TestContextHandler.createTestContext(TestContextHandler.java:89) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94) at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88) at org.jboss.arquillian.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:75) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94) at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88) at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:60) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94) at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88) at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135) at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.test(EventTestRunnerAdaptor.java:111) at org.jboss.arquillian.testng.Arquillian.run(Arquillian.java:158) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.testng.internal.MethodInvocationHelper.invokeHookable(MethodInvocationHelper.java:194) at org.testng.internal.Invoker.invokeMethod(Invoker.java:707) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111) at org.testng.TestRunner.privateRun(TestRunner.java:767) at org.testng.TestRunner.run(TestRunner.java:617) at org.testng.SuiteRunner.runTest(SuiteRunner.java:334) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291) at org.testng.SuiteRunner.run(SuiteRunner.java:240) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1198) at org.testng.TestNG.runSuitesLocally(TestNG.java:1123) at org.testng.TestNG.run(TestNG.java:1031) at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:77) at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:110) at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:106) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189) at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165) at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85) at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75) "
org.testng.AssertJUnit.fail(AssertJUnit.java:59)
org.testng.AssertJUnit.assertTrue(AssertJUnit.java:24)
org.testng.AssertJUnit.assertNotNull(AssertJUnit.java:267)
org.testng.AssertJUnit.assertNotNull(AssertJUnit.java:259)
my.beatiful.tests.JSFUnitTestExample.testInitialPage(JSFUnitTestExample.java:35)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:601)
org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
org.testng.internal.MethodInvocationHelper$1.runTestMethod(MethodInvocationHelper.java:182)
org.jboss.arquillian.testng.Arquillian$2.invoke(Arquillian.java:167)
org.jboss.arquillian.container.test.impl.execution.LocalTestExecuter.execute(LocalTestExecuter.java:60)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:601)
org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)
org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)
org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)
org.jboss.arquillian.container.test.impl.client.protocol.local.LocalContainerMethodExecutor.invoke(LocalContainerMethodExecutor.java:50)
org.jboss.arquillian.container.test.impl.execution.RemoteTestExecuter.execute(RemoteTestExecuter.java:120)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:601)
org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)
org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)
org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)
org.jboss.arquillian.container.test.impl.execution.ClientTestExecuter.execute(ClientTestExecuter.java:57)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:601)
org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
org.jboss.arquillian.container.test.impl.client.ContainerEventController.createContext(ContainerEventController.java:142)
org.jboss.arquillian.container.test.impl.client.ContainerEventController.createTestContext(ContainerEventController.java:129)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:601)
org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
org.jboss.arquillian.test.impl.TestContextHandler.createTestContext(TestContextHandler.java:89)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:601)
org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
org.jboss.arquillian.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:75)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:601)
org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:60)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:601)
org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)
org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.test(EventTestRunnerAdaptor.java:111)
org.jboss.arquillian.testng.Arquillian.run(Arquillian.java:158)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:601)
org.testng.internal.MethodInvocationHelper.invokeHookable(MethodInvocationHelper.java:194)
org.testng.internal.Invoker.invokeMethod(Invoker.java:707)
org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
org.testng.TestRunner.privateRun(TestRunner.java:767)
org.testng.TestRunner.run(TestRunner.java:617)
org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
org.testng.SuiteRunner.run(SuiteRunner.java:240)
org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
org.testng.TestNG.runSuitesSequentially(TestNG.java:1198)
org.testng.TestNG.runSuitesLocally(TestNG.java:1123)
org.testng.TestNG.run(TestNG.java:1031)
org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:77)
org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:110)(... cut ... )
最佳答案
我终于找到了解决这个问题的方法。 JSFUnit 期望某些过滤器正在运行。使用 Servet 3.0
协议(protocol),这些应该自动添加。但他们不是。这就是为什么我们没有被注入(inject)任何东西。
我已经下载了 JSFUnit Arquillian 集成源并找到了需要添加的内容:jsfunit-arquillian-2.0.0.Beta2-sources.jar/org/jboss/arquillian/jsfunit/internals/web-fragment.xml
只需手动将其添加到您的 web.xml
一切都应该按预期工作。以下是相关部分:
<filter>
<filter-name>JSFUnitCleanupTestTreadFilter</filter-name>
<filter-class>org.jboss.jsfunit.arquillian.container.JSFUnitCleanupTestTreadFilter</filter-class>
</filter>
<filter>
<filter-name>JSFUnitFilter</filter-name>
<filter-class>org.jboss.jsfunit.framework.JSFUnitFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>JSFUnitCleanupTestTreadFilter</filter-name>
<url-pattern>/ArquillianServletRunner</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>JSFUnitFilter</filter-name>
<url-pattern>/ArquillianServletRunner</url-pattern>
</filter-mapping>
关于使用 TestNG、JSFUnit 2 和 Arquillian 进行自动化测试的 Maven,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14234277/
我想多次运行一个测试用例。在testng.xml中可以配置吗?如果在测试方法中添加循环,则每次运行的结果将不会受到testng报告的影响。 最佳答案 您不能通过xml来执行此操作,但是可以在@Test
我在 TestNG 中尝试了一些使用硬断言和软断言的示例。虽然软断言按预期工作,但我遇到了硬断言的问题。 根据我从互联网上读到的信息-如果硬断言失败,它不会执行其他测试。 由于 ffPageEleme
我能够在 Eclipse 中完美地运行 testng。但是,我想使用命令行(Win 8)运行它,如不同论坛上所述。以下是我尝试处理错误的不同方法 - 1. java -cp "D:\testng\te
假设我有一个可以并行或串行执行的套件。但是,这样做的决定要留给运行时。启动此套件的常见方法如下: TestNG runner = new TestNG(); if (runInParallel())
如何获得执行TESTNG的方法所花费的时间? sample 测试: @Test(threadPoolSize = 100, invocationCount = 100) public void tes
我发现有一个选项可以通过surefire插件将参数设置为testng xml,然后可以从命令行发送参数。 [...] org.apache.maven.plug
我正在尝试使用这样的命令行运行 testng 测试: C:\Documents and Settings\Administrateur\Bureau\automatic tests testNG>ja
我正在尝试从我的套件文件中删除 testng 参数,因为它们在多个套件中都需要。例如,我有 2 个测试套件,upgrades.xml 和 features.xml。我创建了第三个文件,paramete
目标:并行独立运行 2 个类,其中每个测试将方法名称存储到一个变量中,该变量稍后可以在测试中访问。 问题:当测试并行运行时,它们开始在它们之间共享数据,从而破坏测试。 如果您看到控制台输出这是错误的:
好的,请引用 TestNG doc我可以运行测试 依次 (默认在测试套件中)或在 平行使用 . 现在这是我的 TestNG 配置
我正在尝试从命令行运行TestNG,但这给了我错误。 有人可以告诉我我要去哪里错吗? java -cp C:/TestNG目录/testng-6.2.jar;C:\project目录\src\com\
情况和问题 我有几个测试类,每个类都有几个测试方法。所有测试在后台使用相同的测试数据库。每个测试类初始化其数据库内容,然后在几个测试方法中测试内容。 当我单独运行每个测试时,它们都通过了。但是当我同时
如何让我的 TestNG 报告显示报告中控制台输出的链接?我以前见过 TestNG 这样做,但我现在正在做的一个项目没有显示任何输出,而且我在任何地方都找不到任何说明如何打开它的信息。我尝试在 tes
如果断言失败,如何在 TestNG 中继续执行测试?如何在 TestNG 的 HTML 报告中报告失败? 当我运行以下代码时,执行了断言之后的行,但在报告中未列出断言失败: @Test public
如果断言失败,如何在 TestNG 中继续执行测试?如何在 TestNG 的 HTML 报告中报告失败? 当我运行以下代码时,执行了断言之后的行,但在报告中未列出断言失败: @Test public
我在每个 wiki 使用 TestNG + ReportNG instructions在 gradle 中(我固定在食谱上,因为默认示例对我不起作用)。 我想以某种方式在 TestNG 中捕获控制台输
如何使用 TestNG 自动化功能测试,跨越多个 Java 进程? 我对尝试使用 TestNG 而不是 JUnit 产生了兴趣,因为它声称不仅仅是为单元测试而设计的,但我还没有找到具体的例子来说明如何
如何在测试用例的运行时获取当前正在运行的套件名称?我正在使用下面显示的代码来获取当前套件名称。 监听类: public class SuiteListener implements ISuiteLis
我正在使用 Selenium Webdriver 和 Java 设计一个用于测试的定制自动化框架。 现在出于报告的目的,我正在尝试将 TestNG 框架与我的项目集成。 现在我有一个基于 GUI 的界
出于某种原因,我必须使用旧的 TestNG 库,它没有 "getCurrentXmlTest()).getAllParameters()" API 我应该如何使用testng-5.4-jdk15.ja
我是一名优秀的程序员,十分优秀!