rlisagor / freshen Goto Github PK
View Code? Open in Web Editor NEWClone of the Cucumber BDD framework for Python
License: GNU General Public License v3.0
Clone of the Cucumber BDD framework for Python
License: GNU General Public License v3.0
We have cases where we need to start up a mock (written in Flask). we would like to do it once at the beginning of all the test runs and then just shut it down at the end.
Right now we are forced to start/stop at the beginning of every scenario, since we can only use @after, @before. This slows down the test run considerably
Automated build for Freshen, to do the following:
It is currently not possible to run tests in parallel.
scc is a global variable, so each test writes to it and conflicts with other test that are running and might also be using scc.
Instead a new scc object should be created for each test and made available for the steps to use, so that multiple tests running in parallel will be using their own copy of their local context without interference from other tests that are running.
Hi,
I'm really interested by freshen, since Ruby is not my language of choice, but Python is. One of the key feature of Cucumber, IMHO is that it's translated into 30 languages or so. If you intend to use BDD, you may want to allow your "product owner" to write acceptances tests in his mother tongue. I guess that not many french customers would write acceptance tests in english. Nor Spanish, Hungarian, Klingon people.
I've no idea on how to make it possible, but it would be nice to enable this.
I have to chose between Cenário or Cenario word to represents Scenario, but Freshen is forcing me to write "Cenário|Cenario".
Here is my example:
Funcionalidade: Cadastro de aluno
Como um secretário
Eu gostaria de cadastrar um aluno informando nome e data de nascimento
Para que ele possa ser matriculado em disciplinas
Cenário|Cenario: Cadastro de aluno sem nome deve falhar
Dado que estou na tela de cadastro de aluno
Quando eu tento cadastrar um aluno sem preencher o nome
Então o cadastro não pode ser completado com sucesso
If I choose Cenario or Cenário, I receive the error message:
Traceback (most recent call last):
File "/usr/local/lib/python2.6/dist-packages/Freshen_plugin-0.1-py2.6.egg/freshen/parser.py", line 189, in parse_file
return feature.parseFile(fname)[0]
File "/usr/local/lib/python2.6/dist-packages/pyparsing-1.5.2-py2.6.egg/pyparsing.py", line 1408, in parseFile
raise exc
ParseException: No match found for {{"Cenário|Cenario" | "Esquema do Cenário|Esquema do Cenario"} | {W:(@,abcd...)}...} in /home/francisco/Projetos/post_bdd_django/features/cadastro_aluno.feature (at char 422), (line:10, col:2)
I'll create a fork and try to solve the problem :)
Use twisted.trial.TestCase rather then unittest.TestCase as base class for FreshenTestCase if twisted is installed. This allows for (optional) async testing with freshen.
When you run a Freshen note test with the --with-xunit option, the generated XML file has "runTest" as the name for all entries. It would be great if the "name" attribute would reflect the actual title that is being displayed in the console.
If you have a simple nose test:
def test_nothing():
print 'some debug message'
fail()
then when running this with nose, you get:
$ nosetests
<snip>
NameError: global name 'fail' is not defined
-------------------- >> begin captured stdout << ---------------------
bacon
--------------------- >> end captured stdout << ----------------------
<snip>
FAILED (errors=1)
However, if you have --with-freshen
enabled the lines containing the captured standard out never appear, either for code run as part of a freshen test, or even just as part of standard nose tests.
This makes debugging the failing tests substantially harder, as it's much harder to see why they fail.
Disabling output capture with --nocapture
does allow the output to appear, but removes the beneficial grouping of it by test case that would otherwise be had.
Hi, guys,
Again thanks for your great work of providing a port of cucumber to python language.
Anyway I got an issue using 'tags' and 'Background' in my feature file. Ihave something like this:
@wip
Feature: Using Command class
In order to execute queries through commands on the terminal
As an administrator
I need the Command class for this purpose
Background:
Given I have a command
Scenario: Create a command without queries
And I have no queries
When I request the number of queries on command
Then I should get 0 as result
Scenario: Create a command with queries
Given I have a command
And I have some queries:
...
When I run :
nosetests --with-freshen --rednose --force -v --tags=@wip tests/behavior
It runs only the first scenario using the 'Background' definition, not both scenarios.
Any ideas?
Thanks in advance
Limiting pyparsing to versions below 2.0 makes setup.py work again on python 2.x, like this:
index 64d4bc3..1a98005 100644
@@ -16,7 +16,7 @@ setup(
license = "GPL",
packages = ["freshen", "freshen.test"],
package_data = {'freshen': ['languages.yml']},
Hi,
I came across a situation where I have non-trivial setup (basically a short description of a db table) in my feature file background and I would like to be able to share this setup between feature files (to keep things DRY). I know I could put the setup in the steps implementation, but I'd prefer to keep it in the feature file, because it's easier to see the how the output of certain features correlates with what's in the setup.
I couldn't find any way to share background between features, so I propose we add a new construct: "defined in file" which could be used as a part of a step description and would allow us to specify where a common setup is located (the step implementation would then get a parsed table).
When I created a scenario and had no steps, it gave me the UNDEFINED error in the output...but all the tests were flagged as passed and nose displayed OK at the end.
Also a 0 return code was returned from the process instead of 1 (or some error code) to indicate failure.
This means it's hard for automated builds to know if the tests actually failed or not, since a test that was not run due to undefined steps does not fail the test run.
if that is the default behavior, freshen should offer an option to override it.
Freshen is under tests for using in Gaphor (http://gaphor.sf.net) and there was a test fail with the following output:
ERROR: Start up Gaphor: Launch the application
----------------------------------------------------------------------
ExceptionWrapper
----------------------------------------------------------------------
Ran 1 test in 0.880s
FAILED (errors=1)
This "not nice" output remains in verbose mode.
I think that Freshen can prints at least the stdout, as in unittests.
Consider a utf-8 feature file containing:
Feature: test-feature
Scenario: test-scenario
When I say "имя"
Then no error
If the step 'I say "имя"' throws an exception (external to Freshen), then Freshen throws this error:
Traceback (most recent call last):
File "/Users/emptysquare/.virtualenvs/pymongo/lib/python2.7/site-packages/nose/case.py", line 133, in run
self.runTest(result)
File "/Users/emptysquare/.virtualenvs/pymongo/lib/python2.7/site-packages/nose/case.py", line 151, in runTest
test(result)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/case.py", line 376, in call
return self.run(_args, *_kwds)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/case.py", line 340, in run
result.addError(self, sys.exc_info())
File "/Users/emptysquare/.virtualenvs/pymongo/lib/python2.7/site-packages/nose/proxy.py", line 131, in addError
formatted = plugins.formatError(self.test, err)
File "/Users/emptysquare/.virtualenvs/pymongo/lib/python2.7/site-packages/nose/plugins/manager.py", line 94, in call
return self.call(_arg, *_kw)
File "/Users/emptysquare/.virtualenvs/pymongo/lib/python2.7/site-packages/nose/plugins/manager.py", line 136, in chain
result = meth(_arg, *_kw)
File "/Users/emptysquare/.virtualenvs/pymongo/lib/python2.7/site-packages/freshen/noseplugin.py", line 201, in formatFailure
return (orig_ec, unicode(orig_ev) + '\n\n>> in "%s" # %s' % (unicode(ev.step.match), unicode(ev.step.source_location())), orig_tb)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 1: ordinal not in range(128)
Just installed freshen, django-sane-testing and moved my tests over from lettuce...
Getting the following (pretty much useless) output from freshen (why no feature, scenario details?) :
$ DJANGO_SETTINGS_MODULE=settings PYTHONPATH=.:.. nosetests --rednose --with-django --with-freshen -v regextensions
runTest (freshen.noseplugin.FreshenTestCase) ... passed
runTest (freshen.noseplugin.FreshenTestCase) ... passed
runTest (freshen.noseplugin.FreshenTestCase) ... passed
runTest (freshen.noseplugin.FreshenTestCase) ... passed
runTest (freshen.noseplugin.FreshenTestCase) ... passed
runTest (freshen.noseplugin.FreshenTestCase) ... passed
runTest (freshen.noseplugin.FreshenTestCase) ... passed
runTest (freshen.noseplugin.FreshenTestCase) ... passed
runTest (freshen.noseplugin.FreshenTestCase) ... passed
runTest (freshen.noseplugin.FreshenTestCase) ... passed
runTest (freshen.noseplugin.FreshenTestCase) ... passed
runTest (freshen.noseplugin.FreshenTestCase) ... passed
runTest (freshen.noseplugin.FreshenTestCase) ... passed
runTest (freshen.noseplugin.FreshenTestCase) ... passed
runTest (freshen.noseplugin.FreshenTestCase) ... skipped
runTest (freshen.noseplugin.FreshenTestCase) ... skipped
runTest (freshen.noseplugin.FreshenTestCase) ... skipped
runTest (freshen.noseplugin.FreshenTestCase) ... passed
runTest (freshen.noseplugin.FreshenTestCase) ... skipped
19 tests run in 12.6 seconds.
4 skipped (15 tests passed)
Similar to what happened with the error wrapper before...
it seems freshen doesn't support re-running failed tests (via the nose "--failed" parameter).
When I have a failed test and start adding this parameter to only re-run the failed test, these are the types of errors I am getting:
::
#2 Failure: ValueError (invalid literal for int() with base 10: 'FreshenTestCase.runTest') ... ERROR
======================================================================
ERROR: Failure: ValueError (invalid literal for int() with base 10: 'FreshenTestCase.runTest')
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python2.6/dist-packages/nose-0.11.4-py2.6.egg/nose/plugins/manager.py", line 148, in generate
for r in result:
File "/usr/local/lib/python2.6/dist-packages/freshen-0.2-py2.6.egg/freshen/noseplugin.py", line 163, in loadTestsFromName
name_without_indexes, indexes = self._split_file_in_indexes(name)
File "/usr/local/lib/python2.6/dist-packages/freshen-0.2-py2.6.egg/freshen/noseplugin.py", line 185, in _split_file_in_indexes
indexes = set(int(p) for p in parts)
File "/usr/local/lib/python2.6/dist-packages/freshen-0.2-py2.6.egg/freshen/noseplugin.py", line 185, in <genexpr>
indexes = set(int(p) for p in parts)
ValueError: invalid literal for int() with base 10: 'FreshenTestCase.runTest'
When experimenting with Lettuce (a competing BDD tool), I noticed that when you have undefined steps, it will actually output a skeleton of the required code for a developer to quickly start with, e.g.:
You can implement step definitions for undefined steps with these snippets:
# -*- coding: utf-8 -*-
from lettuce import step
@step(u'Given I have the request body \'(.*)\'')
def given_i_have_the_request_body_group1(step, group1):
assert False, 'This step must be implemented'
@step(u'When I send it to SPS SOAP Service <soap>')
def when_i_send_it_to_sps_soap_service_soap(step):
assert False, 'This step must be implemented'
@step(u'Then I get the HTTP code 500 (Error)')
def then_i_get_the_http_code_500_error(step):
assert False, 'This step must be implemented'
@step(u'Given I have no data in the database')
def given_i_have_no_data_in_the_database(step):
assert False, 'This step must be implemented'
@step(u'When I send request <request> to the SPS SOAP Service <soap>')
def when_i_send_request_request_to_the_sps_soap_service_soap(step):
assert False, 'This step must be implemented'
@step(u'Then I get the HTTP code 204 (No Content)')
def then_i_get_the_http_code_204_no_content(step):
assert False, 'This step must be implemented'
It would be great if Freshen could offer similar functionality in order to improve developer productivity
I'm using freshen with PyDev (and it's nice nose support). The problem is that PyDev is eclipse based and eclipse's terminal doesn't support colors. The following fix will check for the terminal's capability to deal with colors before colorizing output.
The feature file parser seems to pickup the extra newline character as part of the feature which causes it to not correctly match up to steps.
We have some Background setups that are quite expensive in terms of time.
It is very slow to re-run them at the beginning of every scenario.
It would be great if there was a way to define Background, but at a Feature level, not a Scenario level.
e.g.
Feature Background:
...run this only once...
Background:
...run this before every scenario....
It would be great to allow the parser to accept such syntax:
When I create a multi-line step with empty entries | name | value | | a name | its value | | empty | | Then I expect the empty entries to be set to None
Currently, the only way to create empty entries in a table is to have a special keyword and to code logic for that keyword in the steps. Note that transforms provide a way to work around this limitation in Scenario Outline but this approach is unusable for multi-line tables.
Will be good if add step, what work only if all steps success and only if was trooble
There's another problem with "|" operator.
Here is a feature sample (in portuguese):
Funcionalidade: Criação de uma calculadora
Como um matemático preguiçoso
Eu gostaria de contar com uma calculadora
Para que eu não precise mais fazer cálculos na mente
Cenário: Dois números e o operador + deve efetuar a soma destes números
Dado que eu estou na tela da calculadora
Quando eu digito dois números
Então eu devo visualizar o resultado 2 na tela
The keyword "Então" (Then) is the problem, in languages.yml file, the "|" operator is used to allow the use of Entao or Então (ã|a), and this don't works, the same issue with Scenario keyword in portuguese, that I related in Issue #2.
I'll try to fix it on my fork :)
Right now in scenario outlines, when passing in parameters via the Examples table, the substitution only seems to work in single line strings, When passing params to a multiline string """ (e.g. a complex SQL query) the parameter is not being passed and the string comes back as-is (i.e. without the param value being replaced).
I haven't seen a mailing list or any contact information, so i apologize if this is not where discussion is intended. Hopefully this is a bug of some sort :P
Anyway, i seem unable to run freshen with the simple calculator example. Any idea why? Here is my terminal screen after attempting to run freshen. Note that i put the init's in there just to try and figure out what is going on. Oddly enough, they are being compiled, and neither calulator.py nor steps.py are, as seen by the pyc..
(env)me@mine:~/projects/freshen_tests/basic_001$ ls -l
total 5
-rwxrwxrwx 1 me me 281 2010-08-14 18:28 calculator.py
drwx------ 1 me me 4096 2010-08-15 16:15 features
-rwxrwxrwx 1 me me 0 2010-08-15 16:14 __init__.py
-rwxrwxrwx 1 me me 147 2010-08-15 16:15 __init__.pyc
(env)me@mine:~/projects/freshen_tests/basic_001$ ls -l ./features/
total 3
-rwxrwxrwx 1 me me 529 2010-08-14 18:31 addition.feature
-rwxrwxrwx 1 me me 295 2010-08-14 18:33 division.feature
-rwxrwxrwx 1 me me 0 2010-08-15 16:14 __init__.py
-rwxrwxrwx 1 me me 156 2010-08-15 16:15 __init__.pyc
-rwxrwxrwx 1 me me 468 2010-08-14 18:32 steps.py
(env)me@mine:~/projects/freshen_tests/basic_001$ nosetests --with-freshen -v
----------------------------------------------------------------------
Ran 0 tests in 0.000s
OK
(env)me@mine:~/projects/freshen_tests/basic_001$ cd features/
(env)me@mine:~/projects/freshen_tests/basic_001/features$ nosetests --with-freshen -v
----------------------------------------------------------------------
Ran 0 tests in 0.000s
OK
(env)me@mine:~/projects/freshen_tests/basic_001/features$
So yea.. if it was at least an error i could work with it... but i have no idea what is actually wrong, aside from nothingness.
So yea, any help would be much appreciated.
Update: Alright, i seem to be doing something wrong? I found it works great if i define every single feature file.. manually
turkish translation as gist...
Docs should be moved to Sphinx, with a nice template. Maybe look into publishing on http://readthedocs.org/
Like in PyCukes (http://github.com/hugobr/pycukes) and Cucumber, I think that we can internationalize the step decorators.
Here is an example in portuguese:
@dado("que eu digitei (\d+) na calculadora")
def something(num):
pass
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.