コード例 #1
0
ファイル: behave.py プロジェクト: mgoeminne/sismic
def execute_behave(statechart, features, coverage, parameters):
    # Create temporary directory
    with tempfile.TemporaryDirectory() as tempdir:
        # Move statechart inside
        _, statechart_filename = os.path.split(statechart)
        shutil.copy(statechart, os.path.join(tempdir, statechart_filename))

        # Move features inside
        for feature in features:
            _, feature_filename = os.path.split(feature)
            shutil.copy(feature, os.path.join(tempdir, feature_filename))

        # Create an environment file
        with open(os.path.join(tempdir, 'environment.py'), 'w') as environment:
            content = DEFAULT_ENVIRONMENT_CONTENT
            if coverage:
                content += COVERAGE_ENVIRONMENT_CONTENT
            environment.write(content.replace('{{path}}', os.path.join(tempdir, statechart_filename)))

        # Create a steps subdirectory
        os.mkdir(os.path.join(tempdir, 'steps'))

        # Create steps file
        with open(os.path.join(tempdir, 'steps', 'steps.py'), 'w') as step:
            step.write(DEFAULT_STEPS_CONTENT)

        # Execute behave
        # subprocess.call(['behave'] + parameters, cwd=tempdir)
        cwd = os.getcwd()
        os.chdir(tempdir)
        behave_main.main(parameters)
        os.chdir(cwd)
コード例 #2
0
def __run_test_cases():
    """ para correr los escenarios con behave, llamamos al main
        cuando se genera un error lo tomamos y mostramos."""
    try:
        behave_script.main()
    except Exception as e:
        logging.error("Error al ejecutar los steps: " + str(e))
        traceback.print_exc()
コード例 #3
0
    # feature file path
    featureFilePath = ' feature_files_folder/Octopus_People.feature '

    # tag option
    tagOptions = ''
    tagOptions = ' --tags=tag_me '

    # command line argument to capture console output
    commonRunOptions = ' --no-capture --no-capture-stderr -f plain '

    # full list of command line options
    Run_Options = tagOptions + featureFilePath + reporting_allure + commonRunOptions

    # run Behave with Python code
    runner_with_options.main(Run_Options)

    # read result json file
    listOfJsonFiles = glob.glob(reporting_folder_name + "/*.json")
    finalJson = ''
    for cnt in range(0, len(listOfJsonFiles)):
        listOfJsonFiles[cnt] = ' {"' + "Scenario_" + str(
            cnt) + '"' + ' : ' + open(listOfJsonFiles[cnt], 'r').read() + '}'
        if cnt < (-1 + len(listOfJsonFiles)):
            listOfJsonFiles[cnt] = listOfJsonFiles[cnt] + ','
        finalJson = finalJson + listOfJsonFiles[cnt]
    finalJson = '[ ' + finalJson + ' ]'

    # convert json to html
    html_content = json2html.convert(json=finalJson)
    html_report_file = open(reporting_folder_name + '/' + 'index.html', 'w')
コード例 #4
0
    '/data',
    '{}/../reports/blackbox-tests/metrics'.format(cwd),
    '{}/../reports/blackbox-tests/logs'.format(cwd),
    '{}/../reports/blackbox-tests/meta'.format(cwd),
    '{}/../reports/blackbox-tests/behave'.format(cwd),
    '{}/../reports/blackbox-tests/cucumber'.format(cwd),
    '{}/../reports/blackbox-tests/junit'.format(cwd)
  ]:
    os.system('mkdir -p {}'.format(path))
    os.system('rm -rf {}/*'.format(path))

  from behave import __main__ as behave_executable

  print('\nStarting tests')

  exit_code = behave_executable.main(args=' '.join(args))

  with open('{}/../reports/blackbox-tests/behave/results.json'.format(cwd), 'r') as fd_behave:
    cucumber_data = None
    with open('{}/../reports/blackbox-tests/cucumber/results.json'.format(cwd), 'w') as fd_cucumber:
      behave_data = json.loads(fd_behave.read())
      cucumber_data = json.dumps(behave2cucumber.convert(behave_data))
      fd_cucumber.write(cucumber_data)

  Shell.run([
    'json_to_junit',
    '{}/../reports/blackbox-tests/cucumber/results.json'.format(cwd),
    '{}/../reports/blackbox-tests/junit/results.xml'.format(cwd)
  ])

  sys.exit(exit_code)
コード例 #5
0
from sys import argv


@fixture
def fake_data_provider(context: dict, *args, **kwargs) -> None:
    """Create a new fake data provider.

    This fixture will create a new fake data provider to be used during the test steps
    and attach it on the context.

    """
    fake = Faker()
    fake.add_provider("python")
    fake.add_provider("address")

    context.fake = fake


def before_all(context: dict) -> None:
    """Execute actions before all features.

    This lifecycle method will execute a series of actions and functions before any
    feature runs.

    """
    use_fixture(fake_data_provider, context)


if __name__ == "__main__":
    main([arg for arg in argv[1:]])
コード例 #6
0
def start_run_behave(tags: str = "~_Execute_All_"):
    if len(sys.argv) > 1:
        _run_bash_()
    else:
        behave_executable.main('--tags=' + tags +
                               ' --no-skipped --no-snippets')
コード例 #7
0
ファイル: run.py プロジェクト: LorenaH/TN-Automatizacion
from behave import __main__

if __name__ == '__main__':
    __main__.main()
コード例 #8
0

# -*- coding: utf-8 -*-
import re
import sys

from behave.__main__ import main

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(main())
コード例 #9
0
import sys
from logging import getLogger

from behave import __main__ as behave_executable
from structlog import wrap_logger

logger = wrap_logger(getLogger(__name__))


if __name__ == '__main__':

    if len(sys.argv) < 2:
        print('You must supply at least one tag e.g acceptance_tests/features --tags=standalone')
        exit(1)

    behave_format = os.getenv('BEHAVE_FORMAT', 'progress2')

    tags = sys.argv.copy()

    # Strip off program name
    del tags[0]

    all_tags = ''

    for t in tags:
        all_tags += f' --tags={t}'

    logger.warn('Running Acceptance Tests with ' + all_tags)

    behave_executable.main(args=f'--format {behave_format} acceptance_tests/features ' + all_tags)
コード例 #10
0
import sys
from behave import __main__ as runner

if __name__ == '__main__':
    sys.stdout.flush()
    runner.main()

    # runner with options:
    commonOptions = "--no-capture --no-capture-stderr -f plain "  #behave.ini can also be used for common command line options
    file1 = "basics.feature"
    file2 = "basics2.feature"
    folder = "subfeature1/folder1"

    tagList1 = "--tags=smoke"  #run all scenarios having this tag
    tagList2 = "--tags=-smoke"  #Run all scenarios except not having this tag
    tagList3 = "--tags=smoke --tags=automated"  #AND: scenarios having both tags
    tagList4 = "--tags=smoke,automated"  #OR: scenarios having any one of both tags
    forJsonReport = ' -f allure_behave.formatter:AllureFormatter -o reports/json '
    #runner.main() # by default runs all the feature files(including in subfolders) under "features" folder
    #runner.main(commonOptions) #CL arguments to print all the print statements in step def files
    #runner.main(file1+' '+file2) #multifiles run
    #runner.main(folder)  # folder run
    #runner.main(tagList4)  # tag run
    #runner.main(commonOptions+folder+tagList1)  # multiple command line arguments
    #runner.main(forJsonReport)  # for json report
コード例 #11
0
#!/usr/bin/python
# -*- coding: utf-8 -*-

import sys
from behave import __main__ as pythonic_runner_example

if __name__ == '__main__':
    sys.stdout.flush()
    pythonic_runner_example.main()
コード例 #12
0
ファイル: behook.py プロジェクト: ELZo3/project-cylon
def main():
    return __main__.main()
コード例 #13
0
ファイル: __main__.py プロジェクト: WesleyPeng/uiXautomation
# Copyright (c) 2017-2018 {Flair Inc.} WESLEY PENG
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import sys

from behave.__main__ import main

if __name__ == '__main__':
    args = [
        os.path.join(
            os.path.dirname(__file__),
            'features'
        )
    ]

    args += sys.argv[1:]

    sys.exit(main(args))
コード例 #14
0
import sys
from behave import __main__

if __name__ == "__main__":
    sys.stdout.flush()
    __main__.main()
コード例 #15
0
 def _invoke_behave(self, arguments):
     return behave_main.main(arguments)
コード例 #16
0
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
from behave import __main__ as runner_with_options

if __name__ == '__main__':
    sys.stdout.flush()
    featureFilePath = ' feature_file_folder/Scenarios_tagged.feature '
    reportingRelated = ' -f allure_behave.formatter:AllureFormatter -o reporting_folder_json '
    commonRunnerOptions = ' --no-capture --no-capture-stderr -f plain '
    fullRunnerOptions = featureFilePath + reportingRelated + commonRunnerOptions
    runner_with_options.main(fullRunnerOptions)
コード例 #17
0
from behave import __main__ as behave

behave.main()
コード例 #18
0
ファイル: testing.py プロジェクト: joshbenner/mudsling
def run_behave():
    from behave.__main__ import main
    sys.argv[0] = ''
    sys.exit(main())
コード例 #19
0
# Copyright (c) 2017-2018 {Flair Inc.} WESLEY PENG
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import sys

from behave.__main__ import main

if __name__ == '__main__':
    args = [os.path.join(os.path.dirname(__file__), 'features')]

    args += sys.argv[1:]

    sys.exit(main(args))
コード例 #20
0
ファイル: start_behave.py プロジェクト: Aca-jov/superdesk
#!/home/ioan/sd/env/bin/python3.4

# -*- coding: utf-8 -*-
import re
import sys

from behave.__main__ import main

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(main())
コード例 #21
0
 def execute_scenario(self):
     args = self.feature_list
     if hasattr(self, 'report_folder'):
         args = args + ' -f allure_behave.formatter:AllureFormatter -o ' + self.report_folder
     runner_with_options.main(args)