Used to test nitunit test files.

Introduced properties

private var _mbuilder: ModelBuilder

nitc :: NitUnitTester :: _mbuilder

ModelBuilder used to parse test files.
private fun case_match_pattern(case: MPropDef): Bool

nitc :: NitUnitTester :: case_match_pattern

Is the test case name match the pattern option?
fun mbuilder: ModelBuilder

nitc :: NitUnitTester :: mbuilder

ModelBuilder used to parse test files.
protected fun mbuilder=(mbuilder: ModelBuilder)

nitc :: NitUnitTester :: mbuilder=

ModelBuilder used to parse test files.
private fun suite_match_pattern(suite: MClassDef): Bool

nitc :: NitUnitTester :: suite_match_pattern

Is the test suite name match the pattern option?
fun test_module_unit(mmodule: MModule): TestSuite

nitc :: NitUnitTester :: test_module_unit

Compile and execute mmodule as a test suite.

Redefined properties

redef type SELF: NitUnitTester

nitc $ NitUnitTester :: SELF

Type of this instance, automatically specialized in every class

All properties

fun !=(other: nullable Object): Bool

core :: Object :: !=

Have self and other different values?
fun ==(other: nullable Object): Bool

core :: Object :: ==

Have self and other the same value?
type CLASS: Class[SELF]

core :: Object :: CLASS

The type of the class of self.
type SELF: Object

core :: Object :: SELF

Type of this instance, automatically specialized in every class
private var _mbuilder: ModelBuilder

nitc :: NitUnitTester :: _mbuilder

ModelBuilder used to parse test files.
private fun case_match_pattern(case: MPropDef): Bool

nitc :: NitUnitTester :: case_match_pattern

Is the test case name match the pattern option?
protected fun class_factory(name: String): CLASS

core :: Object :: class_factory

Implementation used by get_class to create the specific class.
fun class_name: String

core :: Object :: class_name

The class name of the object.
fun get_class: CLASS

core :: Object :: get_class

The meta-object representing the dynamic type of self.
fun hash: Int

core :: Object :: hash

The hash code of the object.
init init

core :: Object :: init

fun inspect: String

core :: Object :: inspect

Developer readable representation of self.
protected fun inspect_head: String

core :: Object :: inspect_head

Return "CLASSNAME:#OBJECTID".
intern fun is_same_instance(other: nullable Object): Bool

core :: Object :: is_same_instance

Return true if self and other are the same instance (i.e. same identity).
fun is_same_serialized(other: nullable Object): Bool

core :: Object :: is_same_serialized

Is self the same as other in a serialization context?
intern fun is_same_type(other: Object): Bool

core :: Object :: is_same_type

Return true if self and other have the same dynamic type.
fun mbuilder: ModelBuilder

nitc :: NitUnitTester :: mbuilder

ModelBuilder used to parse test files.
protected fun mbuilder=(mbuilder: ModelBuilder)

nitc :: NitUnitTester :: mbuilder=

ModelBuilder used to parse test files.
private intern fun native_class_name: CString

core :: Object :: native_class_name

The class name of the object in CString format.
intern fun object_id: Int

core :: Object :: object_id

An internal hash code for the object based on its identity.
fun output

core :: Object :: output

Display self on stdout (debug only).
intern fun output_class_name

core :: Object :: output_class_name

Display class name on stdout (debug only).
fun serialization_hash: Int

core :: Object :: serialization_hash

Hash value use for serialization
private fun suite_match_pattern(suite: MClassDef): Bool

nitc :: NitUnitTester :: suite_match_pattern

Is the test suite name match the pattern option?
intern fun sys: Sys

core :: Object :: sys

Return the global sys object, the only instance of the Sys class.
fun test_module_unit(mmodule: MModule): TestSuite

nitc :: NitUnitTester :: test_module_unit

Compile and execute mmodule as a test suite.
abstract fun to_jvalue(env: JniEnv): JValue

core :: Object :: to_jvalue

fun to_s: String

core :: Object :: to_s

User readable representation of self.
package_diagram nitc::NitUnitTester NitUnitTester core::Object Object nitc::NitUnitTester->core::Object

Parents

interface Object

core :: Object

The root of the class hierarchy.

Class definitions

nitc $ NitUnitTester
# Used to test nitunit test files.
class NitUnitTester

	# `ModelBuilder` used to parse test files.
	var mbuilder: ModelBuilder

	# Compile and execute `mmodule` as a test suite.
	fun test_module_unit(mmodule: MModule): TestSuite do
		var toolcontext = mbuilder.toolcontext
		var suite = new TestSuite(mmodule, toolcontext)
		# method to execute before all tests in the module
		for mmethod in mmodule.before_all do
			toolcontext.modelbuilder.total_tests += 1
			suite.before_all.add new TestCase(suite, mmethod, toolcontext)
		end
		# generate all test cases
		for mclassdef in mmodule.mclassdefs do
			if not mclassdef.is_test then continue
			if not suite_match_pattern(mclassdef) then continue
			toolcontext.modelbuilder.total_classes += 1

			var test_class = new TestClass

			# method to execute before all tests in the class
			for mmethod in mclassdef.before_all do
				toolcontext.modelbuilder.total_tests += 1
				test_class.before_all.add new TestCase(suite, mmethod, toolcontext)
			end

			var before = mclassdef.before
			var after = mclassdef.after

			for mpropdef in mclassdef.mpropdefs do
				if not mpropdef isa MMethodDef or not mpropdef.is_test then continue
				if not case_match_pattern(mpropdef) then continue
				toolcontext.modelbuilder.total_tests += 1
				var test = new TestCase(suite, mpropdef, toolcontext)
				test.before = before
				test.after = after
				test_class.test_cases.add test
			end

			# method to execute after all tests in the class
			for mmethod in mclassdef.after_all do
				toolcontext.modelbuilder.total_tests += 1
				test_class.after_all.add new TestCase(suite, mmethod, toolcontext)
			end

			suite.test_classes.add test_class
		end
		# method to execute after all tests in the module
		for mmethod in mmodule.after_all do
			toolcontext.modelbuilder.total_tests += 1
			suite.after_all.add new TestCase(suite, mmethod, toolcontext)
		end
		suite.run
		return suite
	end

	# Is the test suite name match the pattern option?
	private fun suite_match_pattern(suite: MClassDef): Bool do
		var pattern = mbuilder.toolcontext.opt_pattern.value
		if pattern == null then return true
		var ps = pattern.split_with("::")
		var p = ps.first
		if ps.length == 1 and p.first.is_lower then return true
		if ps.length == 2 and p.first.is_lower then return false
		if p.has_suffix("*") then
			p = p.substring(0, p.length - 1)
			if suite.name.has_prefix(p) then return true
		else
			if suite.name == p then return true
		end
		return false
	end

	# Is the test case name match the pattern option?
	private fun case_match_pattern(case: MPropDef): Bool do
		var pattern = mbuilder.toolcontext.opt_pattern.value
		if pattern == null then return true
		var ps = pattern.split_with("::")
		var p = ps.last
		if ps.length == 1 and p.first.is_upper then return true
		if ps.length == 2 and p.first.is_upper then return false
		if p.has_suffix("*") then
			p = p.substring(0, p.length - 1)
			if case.name.has_prefix(p) then return true
		else
			if case.name == p then return true
		end
		return false
	end
end
src/testing/testing_suite.nit:30,1--122,3