Hi,

We have a few extensions written in C#.  Our team has a background in development with languages like C# and Java - low-code is a bit new for us.  We have usually found it good to have unit tests for any important functions so that we don't accidentally change the functionality under development.  So we were wondering about how to unit-test methods written in C# extensions for OutSystems.  Has anyone done this? Is there any good way of doing this? Is there some other way of testing that we should rather be looking into? (we already unit-test OutSystems modules and have GUI tests in Canopy).

Hope you have some thoughts on this, thanks in advance :)

- Laura


Hi Laura Vigander,

We can do the unit testing of the c# code in the extension 

1. Open the C# code in the visual studio.

2. Add a main class in the page with instantiating the action (action_name an = new action_name (); an(); )

also add the input parameters if necessary

3. Change the .Class file extension and save

4. add a breakpoint in the main class and necessary actions

5. Compile and run the app in the visual studio

we can start debugging and test the extension,

Note we need to provide the proper input parameters 


Hi,

You can just add a unit testing project to your extension, and use the C# unit testing tool of your choice

Regards,

Daniel

kirit guntuk wrote:

Hi Laura Vigander,

We can do the unit testing of the c# code in the extension 

1. Open the C# code in the visual studio.

2. Add a main class in the page with instantiating the action (action_name an = new action_name (); an(); )

also add the input parameters if necessary

3. Change the .Class file extension and save

4. add a breakpoint in the main class and necessary actions

5. Compile and run the app in the visual studio

we can start debugging and test the extension,

Note we need to provide the proper input parameters 


Thanks for your reply. Am I right in thinking that this would be a manuell unit test, or is there any way of making this automatic?


Daniël Kuhlmann wrote:

Hi,

You can just add a unit testing project to your extension, and use the C# unit testing tool of your choice

Regards,

Daniel

Thanks for your reply.  If you have time, can you tell me a bit about how to add a unit testing project to the extension? Or maybe, do you have a link to more information? I'm a bit new to OutSystems so any help would be much appreciated :)


Solution

Hi Laura,

There are some vidoes that show how to debug extension or add a test project:

https://www.youtube.com/watch?v=B3mXzytlbQw to see how to debug your extension.

https://www.youtube.com/watch?v=D6PL8CHEzd4 another video how to do debugging by logging. This shows how to add a test project to your extension, same way you could add a unit test project.

https://www.outsystems.com/blog/posts/regression-testing-with-nunit/ for using NUnit to automate the BDD Framework tests.

Regards,

Daniel



Solution