===== ESpec Unit Testing Library ===== We will be using the ESPEC unit testing framework (a library developed at York University and now part of the EiffelStudio distribution). On the Prism/Linux workstations and the VM, the ESpec Library is present by default (when creating a new project). If it is your own install, then you need to add the library. ===Add ESpec library=== * Open your project with EiffelStudio * Open “project settings window” from Eiffel Studio (Project → Project Settings …) * Expand the groups section by clicking on the arrow next to it * Select the ESpec library as shown below {{:espec:espec.png?600|}} (To add other libraries, or to add the ESPEC library that comes with your version of eiffelStudio, see [[https://wiki.eecs.yorku.ca/project/eiffel/getting_started:add-library:start|here]]) The ECF file will thus have the following line in it: Change the code in class HELLO_WORLD to the following, in order to test if the ESpec library is working. In the tool bar, select the HELLO_WORLD class and change the class the code below: class HELLO_WORLD inherit ES_TEST create make feature {NONE} -- Initialization make -- Run tests do add_boolean_case (agent t0) --show_errors show_browser run_espec end feature -- tests t0: BOOLEAN do comment("t0: succeed?") Result := false end end To run the tests: * Compile the system (by pressing Ctrl-F7) and wait for the C compilation to complete. After adding a lot of code, it is safer to freeze the system (Shift-Ctrl-F7). * Press the little down arrow next to the run button, and invoke “run workbench system”, that will bring a browser window with the results of your tests. The keyboard shortcut is Ctrl-Alt-F5). {{:espec:espec-red.png?400|}} The test will succeed if you have Result := true (and you will get a green bar). ===Useful links=== * Watch [[https://www.youtube.com/playlist?list=PL5dxAmCmjv_6r5VfzCQ5bTznoDDgh__KS|this]] series of tutorial videos. //**Highly recommended!**// * [[http://www.cse.yorku.ca/~sel/espec/scr/es_test.htm|Writing Unit Tests with ESpec]] * [[https://wiki.eecs.yorku.ca/project/eiffel/getting_started:espec|New ESpec Features]] * [[http://www.cse.yorku.ca/~sel/espec/scr/suite_of_unit_tests.htm|Test Suites]] * [[https://wiki.eecs.yorku.ca/project/eiffel/espec:start|ESpec notes]]