-
Notifications
You must be signed in to change notification settings - Fork 18
UIs to write unit tests
Dinis Cruz edited this page Jan 10, 2015
·
1 revision
There are multiple ways to write UnitTests using the O2Platform and its multiple REPLs.
####Using the FluentSharp REPL
You can consume the NUnit Apis directly on the C# REPL:
Assert.IsTrue(int.MaxValue == 0x7FFFFFFF);
Assert.IsTrue(2==2);
return "all ok";
//using NUnit.Framework
//O2Ref:nunit.framework.dll
which can be re-written like this using the FluentSharp.NUnit apis
(int.MaxValue == 0x7FFFFFFF).assert_Is_True(); //Assert.IsTrue(int.MaxValue == 0x7FFFFFFF);
(int.MaxValue).assert_Is(0x7FFFFFFF);
2.assert_Bigger_Than(1);
2.assert_Is(2); //Assert.IsTrue(2==2);
return "nunit.framework.dll".assembly();
//O2Ref:FluentSharp.NUnit
//using FluentSharp.NUnit
Linked from the main O2 Platform UI, there is a tool called Write for NUnitGUI
- Chose that option to open the UI
- Click on Open Default Test File
- click on the RUN in NUnit GUI (save, compile, open and run) button
- Write a test that fails and see it fail in the UI
- You can also use the Run in NUnit Console link to run the test on the Console (which is a bit faster)
- The Run in NUnit Console also provides a nice visual clue for passing and failing tests
- OWASP O2 Platform in Action Part l: Using C# script to write unit test - by Michael Hidalgo