Generate the NitUnit test file skeleton for mmodule in test_file.

Property definitions

nitc $ NitUnitGenerator :: gen_unit
	# Generate the NitUnit test file skeleton for `mmodule` in `test_file`.
	fun gen_unit(mmodule: MModule, test_file: String): Template do
		var with_private = toolcontext.opt_gen_private.value
		var tpl = new Template
		tpl.addn "module test_{mmodule.name} is test"
		tpl.addn ""
		if with_private then
			tpl.addn "intrude import {mmodule.name}"
		else
			tpl.addn "import {mmodule.name}"
		end
		for mclassdef in mmodule.mclassdefs do
			if mclassdef.mclass.kind != concrete_kind then continue
			tpl.addn ""
			tpl.addn "class Test{mclassdef.name}"
			tpl.addn "\ttest"
			for mpropdef in mclassdef.mpropdefs do
				if not mpropdef isa MMethodDef then continue
				var mproperty = mpropdef.mproperty
				if mpropdef.is_abstract then continue
				if mproperty.is_init then continue
				if not with_private and mproperty.visibility <= protected_visibility then continue
				var case_name = case_name(mpropdef)
				tpl.addn ""
				tpl.addn "\tfun {case_name} is test do"
				tpl.addn "\t\tassert not_implemented: false # TODO remove once implemented"
				tpl.addn ""
				tpl.addn gen_init(mclassdef)
				var args = new Array[String]
				for mparameter in mpropdef.msignature.mparameters do
					tpl.addn gen_decl(mparameter.name, mparameter.mtype, mclassdef)
					args.add mparameter.name
				end
				var return_mtype = mpropdef.msignature.return_mtype
				if return_mtype != null then
					tpl.addn gen_decl("exp", return_mtype, mclassdef)
					tpl.add "\t\tvar res = "
				else
					tpl.add "\t\t"
				end
				tpl.addn gen_call(mpropdef, args)
				if return_mtype != null then
					tpl.addn "\t\tassert exp == res"
				end
				tpl.addn "\tend"
			end
			tpl.addn "end"
		end
		return tpl
	end
src/testing/testing_gen.nit:26,2--75,4