Testing your controllers

Is there any recommended way to run tests on the controllers?

Hi.

We are testing libraries and controllers (in javascript) in our own code, but we have not yet exposed this to 3rd party developers yet. The plan is to allow developers to write javascript tests that is runned automatically on build.

For now, you can look at our lib-* projects ( https://github.com/enonic/xp/tree/master/modules/lib ) for how we test our internal code.

2 Likes

When do you plan to open this up for 3rd party developers?

I am also in the need of writing automated tests for the JS in both controllers and services; would this be possible with XP 6.1.1?

Sorry about the delay. We will try hard to get this into a release before christmas.

2 Likes

Any updates on this?

Hi.

Yes, we have some testing (with mocks) in place now. Will try to make an isloated example of this in next week. But for now you can check out https://github.com/enonic/app-features to see how we test some of the controllers there. Right now you will need to bootstrap the testing with a Java class, but this will go away in the future.

Okay, so do you recommend that we test our controllers in the same way as in the repo you linked to, or wait for an upcoming release?

Looks to me like the xp/assert library is not yet exposed for 3rd party developers, is that correct?

1 Like

It’s exposed. The assert library is not documented, but it’s exposed. Will be documented in 6.4 release.

1 Like

Any updates on testing controllers and documentation on how it works? I find it difficult to understand exactly how to test my controllers. Simple controllers are okay to test, but as controllers get more complex, and especially when using external libraries, it gets complicated.

1 Like

Hi. I will create a little document in the docs for how to test the controllers. Will notify you here when that’s done.

5 Likes

Looking forward to it! :smile:

1 Like

I really think ease of testing should be prioritized in future releases.
At least for me testing is a very important aspect of software developement. :relaxed:

3 Likes

I agree.

It really is the single, major thing that has always been missing in Enonic (CMS and XP). Although I am sure it is possible to figure something out on our own now (using one of several JS-test frameworks out there), I really think some suggestions/examples/documentation on best practice would be great.

Combining this with a library for creating mockups based on content type schemas would be even better. :smile:

1 Like

Were you guys able to document it? I’m really looking forward to that.

Thanks!

3 Likes

Any news on testing controllers?

Hi.

Sorry about this. We tried to get some more functionality around this in 6.8, but will add it to 6.9. I am in the middle of creating a spec on how the new testing framework should work. Will post some ideas here later this week.

Is there any news regarding test best practice?

2 Likes

I don’t know how helpful this particular comment is in itself, but a big +1 on this one from one more user :slight_smile:

We will do some changes here to 6.10. Added an issue on GitHub that can be tracked. https://github.com/enonic/xp/issues/4433

5 Likes

I am also missing the possibility to write tests.
@srs: What is the roadmap for this? Looks like it was removed from a sprint in march?

2 Likes