Showing results for 
Search instead for 
Did you mean: 
Showing results for 
Search instead for 
Did you mean: 

JUnit tests with thingworx-ext-sdk


JUnit tests with thingworx-ext-sdk


I'm trying to write some unit tests for my Java extensions and need to mock some classes.

I ran into this when trying to mock a Thing with certain properties.

Thing t = new Thing();

ThingProperty tp = t.addProperty(new PropertyDefinition("propertyName", "propertyDescription", BaseTypes.Boolean);

tp == null?

How could this be? Then i decompiled the thingworx-ext-sdk to find that most of the methods in the thingworx-ext-sdk are either simply empty (not implemented) or return null or some primitive value.

So, I thought that it would be useful to only use the thingworx-ext-sdk for compilation and the thingworx-sdk for testing, but i couldn't figure out how to make this work.

BTW, I'm using Eclipse as my IDE.

How do others unit tests their java extensions?

5-Regular Member

Hi @Robert Taylor, Try replacing Thing t = new Thing(); with Thing t =ThingUtilities.findThing("NewThingName");

Hi Ankit,

Did you try it? It returns null because the thingworx-ext-sdk doesn't implement this method...that is the problem.

It simply returns null.


Having similar problem when trying to make extension...

Complete example of Custom Authenticator

Also searching for improvments in dev flow of extension...

Do remote debugging support hotswap changed classes in Thingworx?

Hope this improves with some code examples...

i think somewhere in the documentation you can find the information that were not supposed to run junit tests or make standalone applications.

you need to compile your project/ make an extension and then import it via composer.

only then you can debug your code

Just found some KCS documentation on this:

Full coverage unit tests are not possible in ThingWorx, but partial coverage is. If the logic that needs to be preserved is isolated from the statements that require context, then unit tests can be beneficial and functional. Hope this helps!