Changeset 36:4c964b691922 in pyenvjasmine for pyenvjasmine/tests/test_runner.py


Ignore:
Timestamp:
Mar 23, 2018, 9:09:29 AM (6 years ago)
Author:
Mauro Molino <mauro@…>
Branch:
default
Phase:
public
Message:

Selectable engine (phantom with jasmine3, rhino with jasmine1)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pyenvjasmine/tests/test_runner.py

    r33 r36  
    55
    66
    7 class TestsRunner(object):
     7class TestsRunnerRhino(object):
     8
     9    """
     10    Run the full tests using the old rhino+jasmine1 env
     11    """
    812
    913    def test_runner_defaults(self):
     
    1115        Test the runner, using default values (which wil run the demo specs)
    1216        """
    13         jstests = Runner()
     17        jstests = Runner(testing_enviroment='rhino')
    1418        success, stdout = jstests.run()
    1519        assert success
     
    2630        envjasmine_dir = os.path.join(os.path.dirname(here), 'envjasmine')
    2731        jstests = Runner(
     32            testing_enviroment='rhino',
    2833            rootdir=envjasmine_dir,
    2934            testdir=sample,
     
    4752        envjasmine_dir = os.path.join(os.path.dirname(here), 'envjasmine')
    4853        jstests = Runner(
     54            testing_enviroment='rhino',
    4955            rootdir=envjasmine_dir,
    5056            testdir=sample,
     
    6874        envjasmine_dir = os.path.join(os.path.dirname(here), 'envjasmine')
    6975        jstests = Runner(
     76            testing_enviroment='rhino',
    7077            rootdir=envjasmine_dir,
    7178            testdir=sample,
     
    97104        # but we want to test also the case when a test failed
    98105        # and it does not appear in the "Failed:" report
    99         jstests = Runner()
     106        jstests = Runner(testing_enviroment='rhino')
    100107        success = jstests.did_test_pass('')
    101108        assert not success
     
    120127        success = jstests.did_test_pass('Failed: something-not-a-number')
    121128        assert not success
     129
     130class TestsRunnerPhantomjs(object):
     131
     132    """
     133    Run the full tests using the phantom+jasmine3 env
     134    """
     135
     136    def test_write_browser_htmlfile_markup_is_correct(self):
     137        """
     138        Test the created markup
     139        The config file doesn't contain the mock files so jasmine tests
     140        are expected to fail
     141        """
     142        here = os.path.dirname(__file__)
     143        sample = os.path.join(here, 'sample')
     144        browser_conf_file = os.path.join(sample, 'browser.configfile_no_mocks.js')
     145        envjasmine_dir = os.path.join(os.path.dirname(here), 'envjasmine')
     146        jstests = Runner(
     147            testing_enviroment='phantomjs',
     148            rootdir=envjasmine_dir,
     149            testdir=sample,
     150            browser_configfile=browser_conf_file
     151        )
     152        expected = jstests.create_testRunnerHtml()
     153        jstests.write_browser_htmlfile()
     154        success, stdout = jstests.run()
     155        assert not success
     156        assert '2 test(s) FAILED:' in stdout
     157        with open("browser.runner.html",'r') as file:
     158            actual = file.read()
     159            assert expected == actual
     160
     161    def test_runner_with_browser_configfile(self):
     162        """
     163        Test the runner, giving it some parameters incl the browser config file
     164        The config file contains the mock files so jasmine tests are expected
     165        to pass
     166        """
     167        here = os.path.dirname(__file__)
     168        sample = os.path.join(here, 'sample')
     169        browser_conf_file = os.path.join(sample, 'browser.configfile.js')
     170        envjasmine_dir = os.path.join(os.path.dirname(here), 'envjasmine')
     171        jstests = Runner(
     172            testing_enviroment='phantomjs',
     173            rootdir=envjasmine_dir,
     174            testdir=sample,
     175            browser_configfile=browser_conf_file
     176        )
     177        success, stdout = jstests.run()
     178        assert success
     179        assert '0 failures' in stdout
     180
     181    def test_did_test_pass(self):
     182        # there is some coverage done with the previous tests,
     183        # but we want to test also the case when a test failed
     184        # and it does not appear in the "Failed:" report
     185        here = os.path.dirname(__file__)
     186        sample = os.path.join(here, 'sample')
     187        browser_conf_file = os.path.join(sample, 'browser.configfile.js')
     188
     189        jstests = Runner(
     190            testing_enviroment='phantomjs',
     191            browser_configfile=browser_conf_file
     192        )
     193        success = jstests.did_test_pass('')
     194        assert not success
     195        success = jstests.did_test_pass('some random data '*50)
     196        assert not success
     197        success = jstests.did_test_pass('some data FAILED some more data')
     198        assert not success
     199        success = jstests.did_test_pass('some data FAILEDsome more data')
     200        assert not success
     201        success = jstests.did_test_pass('0 failures')
     202        assert success
     203        success = jstests.did_test_pass('0 failures FAILED')
     204        assert not success
     205        success = jstests.did_test_pass('0Failed: failures')
     206        assert not success
     207        success = jstests.did_test_pass('1 test(s) FAILED:')
     208        assert not success
     209        success = jstests.did_test_pass('-11 test(s) FAILED:')
     210        assert not success
     211        success = jstests.did_test_pass('something-not-a-number test(s) FAILED:')
     212        assert not success
Note: See TracChangeset for help on using the changeset viewer.