1 / 17

MXUnit

MXUnit. Vikas Patel. Agenda. What is MXUnit? Why MXUnit? Installation Anatomy of test cases Directory runner & output formats Data provider Testing private methods Built-in Assertions. What is MXUnit?.

aine
Download Presentation

MXUnit

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MXUnit Vikas Patel

  2. Agenda • What is MXUnit? • Why MXUnit? • Installation • Anatomy of test cases • Directory runner & output formats • Data provider • Testing private methods • Built-in Assertions

  3. What is MXUnit? • MXUnit is a unit testing framework for CFML developers, modeled after other xUnit frameworks (JUnit, etc)

  4. Why MXUnit? • Why testing? • Convenience features like directory runner, easy debugging, eclipse plug-in, output formats etc. • Support by Google group

  5. Installation • Download the latest version • Unzip to your webroot; e.g., C:\Inetpub\wwwroot\ • Test the installation e.g. http://localhost:8500/mxunit/

  6. Anatomy of a TestCase • Create component (.cfc), filename either starts or ends with "Test“ • component extends mxunit.framework.TestCase • The TestCase can contain setUp() and tearDown() functions that will run prior to and after each and every test

  7. Anatomy of a TestCase (Cont.) • The TestCase can contain beforeTests() and afterTests() functions that will be run once before and once after all tests • Write public methods in which you can write your assertions • You can run the test by loading it in the browser and suffixing it with "?method=runTestRemote", like so: http://localhost/myapp/tests/MyTest.cfc?method=runTestRemote

  8. TestCase: Example

  9. Directory Runner: Example • Supported Output formats: • HTML (or extjs deprecated) • XML • Junitxml • Query • Array

  10. Data Provider • Basic array data providor • Example

  11. Data Provider (Cont.) • Query data provider • Basic list data provider • Basic Excel/CSV data provider • Basic iterator data provider

  12. Testing Private Methods

  13. Built-in Assertions • assertTrue(boolean condition [,String message]) • assertFalse(boolean condition [, String message]) • assert(boolean condition [,String message]) • assertEquals(any expected, any actual [, String message])

  14. Built-in Assertions (Cont.) • fail(String message) • failNotEquals(any value, any value2 [,String message]) • assertSame(any obj1, any obj2 [,String message]) • assertNotSame(any obj1, any obj2 [,String message])

  15. Built-in Assertions (Cont.) • assertXPath(String xpath, any data, [String text], [String message]) • assertIsTypeOf(component obj, String type) • assertIsXMLDoc(any xml [, String message]) • assertIsArray(any obj1) • assertIsDefined(any obj1)

  16. Built-in Assertions (Cont.) • assertIsEmpty(any obj1) • assertIsEmptyArray(any obj1,[String message]) • assertIsEmptyQuery(any obj1,[String message]) • assertIsEmptyStruct(any obj1,[String message]) • assertIsQuery(any q) • assertIsStruct(any obj)

  17. Thanks

More Related