opensmallworld / munit Goto Github PK
View Code? Open in Web Editor NEWmunit
munit
MUnit tests often requires time consuming preparation ( e.g. starting an application, create design), which not all test cases want to do each time in their setup. Same situation exist for cleanups ( close applications, delete designs) and test case teardown.
Other frameworks like pytest allows to define not only for the test itself a setup / teardown, even for suites and run sessions pytest - Fixture scopes
Question is, which concept has MUnit for this?
Checking the one_time_set_up() and one_time_tear_down() functions shows, that these steps are not executed in each run. It requires that a run with other test classes are executed before or afterwards.
MagikSF> one_time_munit_sample_01.run()
$
one_time_munit_sample_01.one_time_set_up()
one_time_munit_sample_01.set_up()
test_sample_1()
one_time_munit_sample_01.tear_down()
one_time_munit_sample_01.set_up()
test_sample_3()
one_time_munit_sample_01.tear_down()
a sw:mtest_result
MagikSF> one_time_munit_sample_01.run()
$
one_time_munit_sample_01.set_up()
test_sample_1()
one_time_munit_sample_01.tear_down()
one_time_munit_sample_01.set_up()
test_sample_3()
one_time_munit_sample_01.tear_down()
a sw:mtest_result
MagikSF> one_time_munit_sample_02.run()
$
one_time_munit_sample_01.one_time_tear_down()
one_time_munit_sample_02.one_time_set_up()
one_time_munit_sample_02.set_up()
test_sample_2()
one_time_munit_sample_02.tear_down()
one_time_munit_sample_02.set_up()
test_sample_4()
one_time_munit_sample_02.tear_down()
a sw:mtest_result
MagikSF> one_time_munit_sample_01.run()
$
one_time_munit_sample_02.one_time_tear_down()
one_time_munit_sample_01.one_time_set_up()
one_time_munit_sample_01.set_up()
test_sample_1()
one_time_munit_sample_01.tear_down()
one_time_munit_sample_01.set_up()
test_sample_3()
one_time_munit_sample_01.tear_down()
a sw:mtest_result
When there is an error, the error string is appended to the test name in the top right box. You cannot see the complete error. Can you add the contents to the traceback text? Proposed solution below.
_pragma(classify_level=restricted,topic=MUnit)
_private _method test_failure.init_traceback_text()
## Init slot .traceback_text.
#DEBUG show(:test_failure,:|init_traceback_text()|)
_global !traceback!
_try _with error_variable
a_stream << internal_text_output_stream.new()
!traceback!( a_stream, _unset, _false )
a_traceback_text << a_stream.string
_if ( tb << .raised_condition[:traceback] ) _isnt _unset
_then
a_traceback_text << "".concatenation( tb, a_traceback_text )
_endif
a_traceback_text << a_traceback_text.slice( a_traceback_text.index_of(%-),
a_traceback_text.size )
.traceback_text << a_traceback_text
_when error
_if .traceback_text _is _unset
_then
.traceback_text << write_string( "Error getting traceback text ",
" running on the ", _thisthread.name,
" thread", newline_char,
error_variable.report_contents_string,
a_stream.string )
_endif
_endtry
# START CHANGE (2022/08/18 M Field (FCSI)) :
# record the error contents as well in traceback_text
_if .raised_condition _isnt _unset
_then
.traceback_text << .raised_condition.report_string +
%newline + .traceback_text
_endif
# END CHANGE (2022/08/18 mf)
_endmethod
$
munit_test_case
may be deprecated but recent changes broke it unnecessarily.
In particular the changes left a number of unresolved conflict methods on munit_test_case
.
Please resolve the conflicts.
The conflict details:
print_conflict_methods(munit_test_case)
$
method assert_true() *** conflict(assert munit_assert ) *** assert_true() in munit_test_case
method assert_unset() *** conflict(munit_assert assert ) *** assert_unset() in munit_test_case
method assert_not_unset() *** conflict(assert munit_assert ) *** assert_not_unset() in munit_test_case
method assert_is() *** conflict(assert munit_assert ) *** assert_is() in munit_test_case
method assert_is_not() *** conflict(munit_assert assert ) *** assert_is_not() in munit_test_case
Module munit_logging breaks munit when the system temp directory is set to anything other than appdata/local/temp .
Steps to reproduce:
**** Error: Access denied to c:\windows\Smallworld\munit_log.json
file_no_access(function="open file", filename="c:\windows\Smallworld\munit_log.json")
---- traceback: Alchemy-REPL (light_thread 26381049) ----
time=20/07/2019 20:28:25
sw!version=5.2.0.0 (swaf)
os_text_encoding=cp1252
!snapshot_traceback?!=unset
condition.raise() (sys_src/guts/condition.magik:616)
system.file_error() (sys_src/guts/system.magik:1425)
system.prim() (sys_src/guts/system.magik:1753)
system.sys!open_file_output() (sys_src/guts/system.magik:633)
external_text_simple_output_stream.new_appending() (sys_src/streams_external/external_text_simple_output_stream.magik:47)
simple_file_log.new_file_appending() (modules/sw_core/logging/source/simple_file_log.magik:61)
munit_log.new_json_log() (modules\munit_logging\source\munit_log.magik:134)
munit_log.new_json_logging_framework() (modules\munit_logging\source\munit_log.magik:113)
munit_log.get_logger() (modules\munit_logging\source\munit_log.magik:95)
Responsible code:
_pragma(classify_level=restricted, usage={redefinable}, topic={logging})
## Defines the filename and path for the migration log
munit_log.define_shared_constant(:log_filepath,
system.pathname_down(
system.pathname_down(system.pathname_up(system.temp_directory_name), "Smallworld"),
"munit_log.json"),
:private)
$
Proposed fix:
_pragma(classify_level=restricted, usage={redefinable}, topic={logging})
## Defines the filename and path for the migration log
munit_log.define_shared_constant(:log_filepath,
system.temp_file_name("munit_log.json"),
:private)
$
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.