org.testng.internal.ObjectFactoryImpl Java Examples
The following examples show how to use
org.testng.internal.ObjectFactoryImpl.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BaseModelTest.java From activejpa with Apache License 2.0 | 5 votes |
@ObjectFactory public IObjectFactory getObjectFactory(ITestContext context) throws Exception { Class<?> clazz = Class.forName("org.activejpa.enhancer.ActiveJpaAgentLoaderImpl"); Method method = clazz.getMethod("loadAgent"); method.invoke(null); return new ObjectFactoryImpl(); }
Example #2
Source File: ReactiveStreamsArquillianTck.java From microprofile-reactive-streams-operators with Apache License 2.0 | 4 votes |
@Test public void runAllTckTests() throws Throwable { TestNG testng = new TestNG(); ObjectFactoryImpl delegate = new ObjectFactoryImpl(); testng.setObjectFactory((IObjectFactory) (constructor, params) -> { if (constructor.getDeclaringClass().equals(ReactiveStreamsCdiTck.class)) { return tck; } else { return delegate.newInstance(constructor, params); } }); testng.setUseDefaultListeners(false); ResultListener resultListener = new ResultListener(); testng.addListener((ITestNGListener) resultListener); testng.setTestClasses(new Class[]{ ReactiveStreamsCdiTck.class }); testng.setMethodInterceptor(new IMethodInterceptor() { @Override public List<IMethodInstance> intercept(List<IMethodInstance> methods, ITestContext context) { methods.sort(Comparator.comparing(m -> m.getInstance().getClass().getName())); return methods; } }); testng.run(); int total = resultListener.success.get() + resultListener.failed.get() + resultListener.skipped.get(); System.out.println(String.format("Ran %d tests, %d passed, %d failed, %d skipped.", total, resultListener.success.get(), resultListener.failed.get(), resultListener.skipped.get())); System.out.println("Failed tests:"); resultListener.failures.forEach(result -> { System.out.println(result.getInstance().getClass().getName() + "." + result.getMethod().getMethodName()); }); if (resultListener.failed.get() > 0) { if (resultListener.lastFailure.get() != null) { throw resultListener.lastFailure.get(); } else { throw new Exception("Tests failed with no exception"); } } }
Example #3
Source File: BaseJPAResourceTest.java From minnal with Apache License 2.0 | 2 votes |
/** * Note: Kind of hack to ensure that ActiveJPAAgent instruments all the models before they are loaded. * * @param context * @return * @throws Exception */ @ObjectFactory public IObjectFactory getObjectFactory(ITestContext context) throws Exception { ActiveJpaAgentLoader.instance().loadAgent(); return new ObjectFactoryImpl(); }