15 Replies Latest reply on Mar 1, 2017 8:37 PM by smanickam RSS
    grahamall Explorer

    Thingworx Automated Unit Testing and Test Driven Development

    Normally writing in Java I'd write unit tests for my code and although not always possible I try to write them prior to the code (Test First) this means I can run all me test with the click of a button

     

    I'm struggling to see how to automate my testing for Thingworx and I'd be interested in hearing how other people have built automated unit tests?

      • Re: Thingworx Automated Unit Testing and Test Driven Development
        jasong Creator

        At Devicify we are starting to work on an automated testing suite for our own software, but ThWx has nothing built in that I know of. It's definitely not a test first sort of system. I am hoping to find some REST service based testing mechanisms which will ease the pain but that doesn't help with mashups, nor likely security testing. I'm only really commenting here to follow this for future insight from ThWx.

        • Re: Thingworx Automated Unit Testing and Test Driven Development
          paic Collaborator

          Just like in Java as you are building your own unit tests, you can do the same using Thingworx services. There are tools available as well that you could use to help you do more automated testing either on the API execution as well as Mashup behavior.

            • Re: Thingworx Automated Unit Testing and Test Driven Development
              grahamall Explorer

              Thank up for replying

               

              Do you have any examples\tutorials? The Java test frameworks are very mature now and patterns exist for  mocking, testing and assertions - I think that Thingworx has equivalents yet.

               

              I'm considering using SoapUI for testing and while this should be OK for system, integration and acceptance testing I'm not sure how suited it will be for units tests - I'll update this answer when I have tried.

            • Re: Thingworx Automated Unit Testing and Test Driven Development
              mattwar Explorer

              Existing Thingworx services as well as custom services written as Javascript services or Java extension services can be tested using Testng to call those REST API services.  These would be considered integration/interoperability/functional tests.  From a unit test perspective JUnit with mocking frameworks like mockito, powermock can be used.

              • Re: Thingworx Automated Unit Testing and Test Driven Development
                carlesc Ninja

                We had build our Testing Suite on TW itself using javascript code and API Keys to call own build services, not hard to develop. Here how it looks like:

                Captura de pantalla 2017-02-28 09.11.59.png

                  • Re: Thingworx Automated Unit Testing and Test Driven Development
                    smanickam Newbie

                    Could you please let me know on which automation Testing tool you build the Testing Suite to test Thinkworx services?

                    Let me know some what in detail step by step where and how to build.

                    1.  Can we have your automation Testing suite & test date at our local system?

                    2. Will your test suite can be used for Regression test execution for Multiple services of IoT?

                    3.  I am Curious to build the similar framework for automating all my services, Could you please share your Test Suite Architecture?

                    It will be great if you could attach your Test Suite architecture document? Thanks...

                      • Re: Thingworx Automated Unit Testing and Test Driven Development
                        carlesc Ninja

                        Hi Sundar,

                         

                        We built on top of TW with TW itself ( Javascript Server Side Services ).

                         

                        1. It's not ready as a component, but could be done with some effort.

                         

                        2. I don't know if it's exactly what you are searching for, but for each Test Set we have an expected result and it can check if the service returns exactly this result or not ( event if it's an Infotable --> It will check row/column value ). At the previous Screenshot you can see at the bottom right on the left the result and on the right the expected result.

                         

                        3. What does you mean on sharing our Test Suite Architecture?

                         

                        We are a small team and for now we don't have it documented. But some features:

                         

                        1. Predefined Test Set List:
                          1. User --> User in whom context execute the Test Set
                          2. thingName
                          3. serviceName
                          4. params
                          5. checkResult --> If it has to check the result or not
                          6. resultBaseType
                          7. result ( the expected result if checkResult==true, it supports almost any kind of TW baseTypes, even InfoTables )
                          8. executionMillisMax --> Kind of alarm system in order to detect a service which last longer than previous executions --> This belongs more to Performance Testing for which we had built a totally different suite as requisites for performance testing are different.
                        2. User Impersonation through automatically created AppKeys --> For now it needs Administrator Interaction with the Browser and Incognito mode
                        3. Customer Based Test Set --> Our solution it's a multitenant one, and we may have System Entities and Customer Based Entities which could belong to a totally different tests sets.

                         

                        Missing things:

                        • History execution ( to see executioMillis )
                        • Recurrent execution --> Automatically call Test Sets with a timer in order to detect bugs on the run ( it's not just code that can break result data, maybe malformed data can do it on the run ) --> To implement correctly that could be amazing if TW guys implements an Impersonation feature when the current execution it's done by Administrator.
                    • Re: Thingworx Automated Unit Testing and Test Driven Development
                      smanickam Newbie

                      Automation testing framework can be doable for TW services

                      with the Testing tool Perfecto Mobile, Selenium, SOAPUI and LoadRunner ?