Giter Club home page Giter Club logo

mgunit's Introduction

mgunit

Simple testing in IDL

mgunit is a unit testing framework modeled on other xUnit testing frameworks. The goal is to allow easy creation and reporting of results of tests, while still allowing for many different testing situations. Simple naming conventions replace formal creation of hierarchies and specification of tests. This allows test suites to be created with a minimum of code beyond the actual code of the tests themselves.

The basic structure of mgunit is that tests are created by subclassing MGutTestCase, tests can be grouped together into suites for convenience by subclassing MGutTestSuite, and tests are run my calling MGUNIT. Various convenience routines are included, such as the ASSERT routine which is useful for making an assertion during a test.

See "Using mgunit" in the docs/ directory for more details about using mgunit.

See the Releases page in the wiki for downloads.

mgunit's People

Contributors

kimyx avatar mandrakos avatar mgalloy avatar subagonsouth avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

mgunit's Issues

Create tools for testing GUIs

It would be useful to be able to insert an event handler (an EVENT_FUNC?) into the top-level base which would record each event in a file. Then a separate event player would be needed to play back the events recorded previously. This would need a mechanism to handle widget identifiers in the events that would not necessarily be the same in the playback (maybe by using UNAMEs?).

Bug in mguttestsuite__define.pro

On line 504 of mguttestsuite__define.pro :
if folder[0] eq '/' then $
folder is a string, and folder[0] is meant to get the first character of the string. That line should be changed to:
if strmid(folder, 0, 1) eq '/' then $

As is, it does not allow for absolute paths as indicated in the documentation.

Property based testing

Adding the ability to do property based testing to mgunit would help find more bugs.

To do property based tests, you would write methods that take parameters and don't start with "test." Then the actual test methods would call a routine, mgunit_proptest, that calls the test method with the given keywords.

For example, to test the routine mg_n_smallest:

function mg_n_smallest_ut::check_size, array=array, n=n
  compile_opt strictarr

  result = mg_n_smallest(arr, n)
  assert, n_elements(result) eq n
  return, 1
end

function mg_n_smallest_ut::test_size
  compile_opt strictarr

  mgunit_proptest, self, 'check_size', $
                   array=mgunit_array(mgunit_float()), $
                   n=mgunit_long(min_value=0)

  return, 1
end

pro mg_n_smallest_ut__define
  compile_opt strictarr

  define = { mg_n_smallest_ut, inherits MGutLibTestCase }
end

Other features:

  • mgunit should write an explicit unit test when a property based test fails.

mgunit test issue

Hi Michael Galloy,

I came across a bug in mgunit 1.5.0 the other day and wanted to send it your way.

In creating a certain test I keep getting the failure:

% Restored file: MGUNIT.
"All tests" test suite starting (1 test suite/case, 1 test)
  "mmm_test_mmm_make_mgunit_fail_ut" test case starting (1 test)
    test_for_error: failed "IDL_CONTAINER::ADD: Object reference type required in this context: RESULT1." (0.001862 seconds)
  Results: 0 / 1 tests passed, 0 skipped
Results: 0 / 1 tests passed, 0 skipped

I'm currently using unzipped mgunit 1.5.0 but found the test to pass when I went back and used mgunit 1.4.0.

Here is a link to the code to reproduce it:

https://gist.github.com/andywinhold/fdd820f44b14fbceed50

Keep a count of skipped tests

Skipped tests should be kept track of, so the test runner could, for example, say at the end: "3/4 tests passed, 1 skipped".

Include idldoc dependency.

It is not currently possible to simply check out trunk and "make dist". The Makefile attempts to build the API docs, which relies on idldoc, which is not included in the source distribution. Please either add the necessary files to the project, enhance the Makefile to grab the necessary files with wget, or pull in the necessary files through svn:externals.

Include mg_src_root dependency.

It is not currently possible to simple check out trunk and "make dist". The source relies on mg_src_root, which is not included in the source distribution. If maintained as a separate project, please pull in with svn:externals.

Make script/target to create distribution

We need a script or CMake target to builds the docs, compile the code into a .sav file, build the .zip files, etc. in order to consistently make the distribution (in two varieties: dist and srcdist).

Multiprocessing mgunit?

Is there a built in way to multi-thread a suite of mgunit tests, perhaps utilizing your mg_pool() class? It would be great to have a keyword option on mgunit directly and have it utilize mg_pool() internally to divide up the tests, aggregate the logs, etc. I'm working with a suite of tests that currently takes over an hour to run, so this would be a huge benefit.

Runners requiring filename

Hi,

Nice framework, but got an 'OPENW: Null filename not allowed' with
IDL> mguint, 'mytest_ut', /junit
due to _filename being set to ''. The change below resolves the issue:

--- a/mgunit/src/mgunit.pro
+++ b/mgunit/src/mgunit.pro
@@ -146,7 +146,7 @@ pro mgunit, tests, $

 for i = 0L, n_elements(runnerName) - 1L do begin
   f = n_elements(f) eq 0L ? 0L : i mod n_elements(filename)
  •  _filename = n_elements(filename) eq 0L ? '' : filename[f]
    
  •  _filename = n_elements(filename) eq 0L ? !NULL : filename[f]
    
    _color = (keyword_set(color) || mgunit_findIfTty()) $
    && (n_elements(filename) eq 0L || strlen(filename[f]) eq 0L)
    testRunner->add, obj_new(runnerName[i], $

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.