Topic
  • 2 replies
  • Latest Post - ‏2013-10-22T07:47:07Z by OttoDiesel
SystemAdmin
SystemAdmin
16727 Posts

Pinned topic Running RFT tests from C# or NUnit

‏2007-08-14T15:47:40Z |
Is there a means of calling RFT test scripts from out side RFT, as in a C# project? Im trying to write some tests that may be called from Nunit.

Thanks
Updated on 2007-09-03T14:38:29Z at 2007-09-03T14:38:29Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    16727 Posts

    Re: Running RFT tests from C# or NUnit

    ‏2007-09-03T14:38:29Z  
    Hello
    We want do same in Java environment.
    There is impossible to run Script1.TestMain because of exception com.rational.test.ft.sys.Transaction$NotInTransactionException.
    I think there is need to initialize RFT context.

    Manually beginning transaction like this:

    com.rational.test.ft.sys.Transaction.begin();
    Script1 qqq;
    qqq = new Script1();
    qqq.testMain(null);
    Transaction.end();

    threw other error:
    Exception in thread "main" java.lang.Error: only a client test context can begin a transaction
    at com.rational.test.ft.sys.Transaction.begin(Transaction.java:148)
    at Test1.main(Test1.java:16)

    At this point we stopped our investigations
    Any ideas ??
  • OttoDiesel
    OttoDiesel
    51 Posts

    Re: Running RFT tests from C# or NUnit

    ‏2013-10-22T07:47:07Z  
    Hello
    We want do same in Java environment.
    There is impossible to run Script1.TestMain because of exception com.rational.test.ft.sys.Transaction$NotInTransactionException.
    I think there is need to initialize RFT context.

    Manually beginning transaction like this:

    com.rational.test.ft.sys.Transaction.begin();
    Script1 qqq;
    qqq = new Script1();
    qqq.testMain(null);
    Transaction.end();

    threw other error:
    Exception in thread "main" java.lang.Error: only a client test context can begin a transaction
    at com.rational.test.ft.sys.Transaction.begin(Transaction.java:148)
    at Test1.main(Test1.java:16)

    At this point we stopped our investigations
    Any ideas ??

    This seems to be a working solution for RFT 8.5.0.1:

        new com.rational.test.ft.sys.TestContextClient();
        com.rational.test.ft.sys.TestContextClient.create();

        registerClientServices();

        // Copied from decomiled source: com.rational.test.ft.application.CoreActivator.registerClientServices()
        private void registerClientServices() {
            IServiceBroker sb = ServiceBroker.getServiceBroker();
            sb.provideService(IClientClassLoaderService.class.getName(), new FtClientClassLoaderService());
            sb.provideService(IClientOptionValidater.class.getName(), new ClientOptionValidator());
            sb.provideService(IObjectMapPersistentState.class.getName(), new ObjectMapPersistentState());
            sb.provideService(IDatastoreService.class.getName(), new ClientDatastoreService());
            sb.provideService(IDirOrJarServiceProvider.class.getName(), new ClientDirOrJarServiceProvider());
            sb.provideService(ILocaleMessage.class.getName(), new ClientLocaleMessage());
            sb.provideService(ITestObjectProvider.class.getName(), new TestObjectProvider());
            sb.provideService(ITestContextService.class.getName(), new ClientTestContextService());
        }

    After the first three codelines you can use very much of the RFT API like RationalTestScript.find(...) for example.

    I converted a RFT test script to a POJO and used the solution above. It worked well on the first glance.

    The playback monitor is not yet working with this solution. Bit this is not so important I think. You would access it in your code like: RFTCore.getScriptExecutionArgs().getScriptPlaybackMonitor(). It is because "com.ibm.rational.test.ft.extensions.ScriptPlaybackExtensionUtil" calls "Platform.getExtensionRegistry().getExtensionPoint("com.ibm.rational.test.ft.clientbase.ScriptPlayback");" But "Platform.getExtensionRegistry()" throws an exception. Perhaps a solution could be found so that the extension registry acts as if one would start a RFT script. I found a thread about this topic, but I had not yet tried the solutions meantioned there: http://www.eclipsezone.com/eclipse/forums/m92168379.html

    You can use it even from command line by starting a Java POJO .class instead of having to use the RFT startup class.

    If this really proves to be working as expected, then you could use RFT for example in JUnit tests or in other testing frameworks without any problems, or with Maven.

    This solution seems to be totally undocumented and the IBM Rational support did not know about it. Don't ask me how I discovered it. I reverse engineered RFT but I also had a lot of luck.

    Updated on 2013-10-22T13:08:52Z at 2013-10-22T13:08:52Z by OttoDiesel