[erlang-bugs] Common Test 1.6.1 - Surefire

Jóvan Sean Dippenaar jovan@REDACTED
Sat May 5 14:01:14 CEST 2012


Errors in Common Test 1.6.1 - cth_surefire.erl


cth_surefire.erl has a two errors :

1. " on_tc_fail( TC, Res, State)" should be "on_tc_fail(_Tc, Res, State)", as the TC causes a bad match on inside the function with regards to the TC record. 
    this causes surefire results to generate .xml which indicate passed tests when in actual fact the tests have failed.

2. failures in "init_per_suite" cause "on_tc_skip" to be called which is correct up until "on_tc_skip" is called for "end_per_suite" as well. This also means that 
    "post_end_per_suite" is never called, which is the problem. As "post_end_per_suite" takes all test cases results and places in State#state{ test_suites ).
    This is important as the xml generation on terminate iterates thru the test suites.

    here's a fix :

on_tc_skip(Tc, Res, State) ->
    TCs = State#state.test_cases,
    [TC | RestTCs ] = TCs,
    {CurTC, CurRestTCs} = case TC#testcase.failure of
						    	passed -> {TC, RestTCs};
						    	_OtherFailure -> 
						    		Name = atom_to_list(Tc),
						    		NTC = new_tc_rec(Name, State#state{timer = now()}),
						    		{NTC, TCs}
						    end,
    
    NewTC = CurTC#testcase{ 
    						failure = {skipped, lists:flatten(io_lib:format("~p",[Res])) } 
						   },
    NewState = State#state{ test_cases = [NewTC | CurRestTCs]},
     
    case Tc of
    	end_per_suite ->
    		 Suite = get_suite(NewState, TCs),
		    AltState =  NewState#state{ test_cases = [],  test_suites = [Suite | NewState#state.test_suites]},
    		AltState;
    	_Other ->
    		NewState
    end.




/ Jovan Sean Dippenaar - Aeonmind Enterprises

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PastedGraphic-7.pdf
Type: application/pdf
Size: 35462 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20120505/c2713932/attachment.pdf>
-------------- next part --------------




More information about the erlang-bugs mailing list