Structuring unit tests

Richard A. O'Keefe ok@REDACTED
Mon Apr 18 04:59:52 CEST 2005


"Gaspar Chilingarov" <nm@REDACTED> wrote:
	another question - how do you following thing in Erlang?
	in OO world I can define some object, then inherit from it in unit test, and
	override some functions. Thus i can create necessary environment for tested
	class. How this can be implemented in Erlang? I also accept answers "this is
	not an erlangish way at all" :)
	
It couldn't be easier if you follow the advice to have a test/1 function
that is exported instead of calling the functions individually.

-module(foo).
-export([test/1]).
    
test(1) -> ...;			% The test cases you want to
test(77) -> ...;		% override or
test(102) -> ...;		% add go here
test(X) -> bar:test(X).		% Then you "inherit" from module bar.




More information about the erlang-questions mailing list