利用者:Dhandeo/SummerOfCode2008

提供: wiki
移動先: 案内検索

Converting import / export scripts to accept parameters

Next task is to make import / export scripts callable with parameters directly by automated testing routines, bypassing all the user interface elements.

The file with the modified formats with their GUI options is here

There is more documentation available about import and export scripts.

Setting up the skeleton for automated testing

The idea is to write a python script which will drive all the import / exporters one by one, and during each run making sure that the translators are doing what they are supposed to do.

Unit testing

'unittest' module in Python unit testing framework is included in standard python library since version 2.1 (and blender current versions use 2.5, so if they have access to external python, it will run it)

It makes it easier to write test cases, and run them at a command and catch and report exceptions if any.

The output of latest commit


E:\Blender_workspace\release\scripts>"c:\Program Files\Blender Foundation\Blende
r\blender.exe"  -b ".\TestData\export_test.blend" -P "im_ex_test_suite.py" -v
Compiled with Python version 2.5.
Checking for installed Python... got it!
Exporters test suit
Check whether DXF files exported are in good condition ... ok
Check whether OBJ files exported are in good condition ... ok
Check whether OBJ files exported are in good condition ... ok
Check whether STL files exported are in good condition ... FAIL
Check whether OBJ files exported are in good condition ... ok

======================================================================
FAIL: Check whether STL files exported are in good condition
----------------------------------------------------------------------
Traceback (most recent call last):
  File "im_ex_test_suite.py", line 28, in testSTL
    self.assertEqual(999, self.knownValues[0][0])
AssertionError: 999 != 121

----------------------------------------------------------------------
Ran 5 tests in 0.015s

FAILED (failures=1)

Blender quit

Interpretation

This is currently just sanity check. When the test suite invoked from the command line as shown, it runs each of the test cases defined ExportTest class


class ExportersTest(unittest.TestCase):
    def setUp(self):
        # Should fillup with the actual known geometry information
        self.knownValues = ((121, 'Vertices'),
                            (300, 'Edges'),
                            (233, 'Facets'),)

    def testSTL(self):
        """Check whether STL files exported are in good condition """
        Blender.Save('TestData\\export_test.stl',1);
        # Write code here to make sure stl file written is in good health
        self.assertEqual(999, self.knownValues[0][0])


For example the testSTL case tried to export the loaded blend file as STL file. If no exception is returned the test is considered a success.

Here it is failed artificially by comparing known number with 999. In white box testing this assertEqual statement will be actually verifying the known numbers to those returned from export functionality.

The aspects of input output features to test

(being updated as the coding evolves)

Black Box testing

  • First of all Black Box testing, without actually modifying any of the export routines
    • Health check - The scripts are executed completely without generating any exceptions. For this the test calls each routine to export a single selected object.
      • Some file formats are supposed to contain a single object

export one or more objects

    • Sanity check - Where the files exported by Blender can be imported back into blender. This is possible for all formats for which both importers and exporters exist.

White box testing

Probe into the functionality, actually modifying the scripts to report back the success of the information just processed. This returned information will be compared with the known details of the test .blend file.



Synopsis of proposal

Automated testing framework for import / export scripts

The proposed project is about an automated testing framework for import / export scripts of Blender.

Blender (2.45) currently includes twenty file formats for importing and translators for exporting geometry with various degrees of completeness and supported features. Each of those formats will be studied for the exact features supported, re-factored for allowing consistent (same for all formats) and format specific unit tests (if applicable).


The most important deliverable will be an automated testing suit, with corresponding data files, for testing all implemented functionalities of import and export scripts of blender. It will include a detailed document (wiki) enlisting all the supported data exchange formats and their features and designed tests for each of them.

A code template for addition of new translator for a new format. with testing class and methods already included.