Your SlideShare is downloading. ×
MXUnit Vikas Patel
Agenda <ul><li>What is MXUnit? </li></ul><ul><li>Why MXUnit? </li></ul><ul><li>Installation </li></ul><ul><li>Anatomy of t...
What is MXUnit? <ul><li>MXUnit is a unit testing framework for CFML developers, modeled after other xUnit frameworks (JUni...
Why MXUnit? <ul><li>Why testing? </li></ul><ul><li>Convenience features like directory runner, easy debugging, eclipse plu...
Installation <ul><li>Download the latest version </li></ul><ul><li>Unzip to your webroot; e.g., C:Inetpubwwwroot  </li></u...
Anatomy of a TestCase <ul><li>Create component (.cfc), filename either starts or ends with &quot;Test“ </li></ul><ul><li>c...
Anatomy of a TestCase (Cont.) <ul><li>The TestCase can contain beforeTests() and afterTests() functions that will be run  ...
TestCase: Example
Directory Runner: Example <ul><li>Supported Output formats: </li></ul><ul><ul><li>HTML (or extjs deprecated) </li></ul></u...
Data Provider <ul><li>Basic array data providor </li></ul><ul><li>Example </li></ul>
Data Provider (Cont.) <ul><li>Query data provider </li></ul><ul><li>Basic list data provider </li></ul><ul><li>Basic Excel...
Testing Private Methods
Built-in Assertions <ul><li>assertTrue(boolean condition [,String message]) </li></ul><ul><li>assertFalse(boolean conditio...
Built-in Assertions (Cont.) <ul><li>fail(String message) </li></ul><ul><li>failNotEquals(any value, any value2 [,String me...
Built-in Assertions (Cont.) <ul><li>assertXPath(String xpath, any data, [String text], [String message]) </li></ul><ul><li...
Built-in Assertions (Cont.) <ul><li>assertIsEmpty(any obj1) </li></ul><ul><li>assertIsEmptyArray(any obj1,[String message]...
Thanks
Upcoming SlideShare
Loading in...5
×

Mxunit

534

Published on

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
534
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Mxunit"

  1. 1. MXUnit Vikas Patel
  2. 2. Agenda <ul><li>What is MXUnit? </li></ul><ul><li>Why MXUnit? </li></ul><ul><li>Installation </li></ul><ul><li>Anatomy of test cases </li></ul><ul><li>Directory runner & output formats </li></ul><ul><li>Data provider </li></ul><ul><li>Testing private methods </li></ul><ul><li>Built-in Assertions </li></ul>
  3. 3. What is MXUnit? <ul><li>MXUnit is a unit testing framework for CFML developers, modeled after other xUnit frameworks (JUnit, etc) </li></ul>
  4. 4. Why MXUnit? <ul><li>Why testing? </li></ul><ul><li>Convenience features like directory runner, easy debugging, eclipse plug-in, output formats etc. </li></ul><ul><li>Support by Google group </li></ul>
  5. 5. Installation <ul><li>Download the latest version </li></ul><ul><li>Unzip to your webroot; e.g., C:Inetpubwwwroot </li></ul><ul><li>Test the installation e.g. http://localhost:8500/mxunit/ </li></ul>
  6. 6. Anatomy of a TestCase <ul><li>Create component (.cfc), filename either starts or ends with &quot;Test“ </li></ul><ul><li>component extends mxunit.framework.TestCase </li></ul><ul><li>The TestCase can contain setUp() and tearDown() functions that will run prior to and after each and every test </li></ul>
  7. 7. Anatomy of a TestCase (Cont.) <ul><li>The TestCase can contain beforeTests() and afterTests() functions that will be run once before and once after all tests </li></ul><ul><li>Write public methods in which you can write your assertions </li></ul><ul><li>You can run the test by loading it in the browser and suffixing it with &quot;?method=runTestRemote&quot;, like so: http://localhost/myapp/tests/MyTest.cfc?method=runTestRemote </li></ul>
  8. 8. TestCase: Example
  9. 9. Directory Runner: Example <ul><li>Supported Output formats: </li></ul><ul><ul><li>HTML (or extjs deprecated) </li></ul></ul><ul><ul><li>XML </li></ul></ul><ul><ul><li>Junitxml </li></ul></ul><ul><ul><li>Query </li></ul></ul><ul><ul><li>Array </li></ul></ul>
  10. 10. Data Provider <ul><li>Basic array data providor </li></ul><ul><li>Example </li></ul>
  11. 11. Data Provider (Cont.) <ul><li>Query data provider </li></ul><ul><li>Basic list data provider </li></ul><ul><li>Basic Excel/CSV data provider </li></ul><ul><li>Basic iterator data provider </li></ul>
  12. 12. Testing Private Methods
  13. 13. Built-in Assertions <ul><li>assertTrue(boolean condition [,String message]) </li></ul><ul><li>assertFalse(boolean condition [, String message]) </li></ul><ul><li>assert(boolean condition [,String message]) </li></ul><ul><li>assertEquals(any expected, any actual [, String message]) </li></ul>
  14. 14. Built-in Assertions (Cont.) <ul><li>fail(String message) </li></ul><ul><li>failNotEquals(any value, any value2 [,String message]) </li></ul><ul><li>assertSame(any obj1, any obj2 [,String message]) </li></ul><ul><li>assertNotSame(any obj1, any obj2 [,String message]) </li></ul>
  15. 15. Built-in Assertions (Cont.) <ul><li>assertXPath(String xpath, any data, [String text], [String message]) </li></ul><ul><li>assertIsTypeOf(component obj, String type) </li></ul><ul><li>assertIsXMLDoc(any xml [, String message]) </li></ul><ul><li>assertIsArray(any obj1) </li></ul><ul><li>assertIsDefined(any obj1) </li></ul>
  16. 16. Built-in Assertions (Cont.) <ul><li>assertIsEmpty(any obj1) </li></ul><ul><li>assertIsEmptyArray(any obj1,[String message]) </li></ul><ul><li>assertIsEmptyQuery(any obj1,[String message]) </li></ul><ul><li>assertIsEmptyStruct(any obj1,[String message]) </li></ul><ul><li>assertIsQuery(any q) </li></ul><ul><li>assertIsStruct(any obj) </li></ul>
  17. 17. Thanks

×