User Tools

Site Tools


eiffel:espec:start

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

(To add other libraries, or to add the ESPEC library that comes with your version of eiffelStudio, see here)

The ECF file will thus have the following line in it:

<library name="espec" 
location="$ISE_LIBRARY\contrib\library\testing\framework
\espec\library\espec-safe.ecf"/>

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).

The test will succeed if you have Result := true (and you will get a green bar).

  • Watch this series of tutorial videos. Highly recommended!
eiffel/espec/start.txt · Last modified: 2016/07/14 18:47 by marina