"You need tests that don't break when you refactor. When you use dynamic mocks, tests tend to fail whenever you make changes in SUTs. Even though you have tests, they don't enable refactoring."
seen from United States
seen from Dominican Republic

seen from United States

seen from India
seen from Malaysia

seen from United States
seen from United States

seen from United States

seen from Russia

seen from United States
seen from United States
seen from Germany
seen from China
seen from Venezuela
seen from Morocco
seen from Germany
seen from United States

seen from United States

seen from United States

seen from United States
"You need tests that don't break when you refactor. When you use dynamic mocks, tests tend to fail whenever you make changes in SUTs. Even though you have tests, they don't enable refactoring."
Apache Maven – How to skip the unit test execution
Apache Maven – How to skip the unit test execution
In Apache Maven, we can pass the parameter -Dmaven.test.skip=true to skip the entire unit test while executing Maven goals such as mvn package. By default, Maven will execute the unit tests automatically and if any unit tests fail then the build process also fails. Following are some scenarios where you might want to skip failures or skip unit test execution:1) Pipeline has a specific stage for…
View On WordPress
Test Automation ⚙ Test Strategy and Management 💻 mob/desk📱
Test Automation fin-test.net ⚙ Test Strategy and Management 💻 mob/desk📱
Testing types fin-test.net
Test automation is a significant investment in any software testing project. Cost and benefits should be weighed before automation is started as it takes time to develop. As a matter of fact, test automation does not differ from other software development activities. Automation requires an initial investment of time, training, and licenses. There is also ongoing maintenance required, and even application changes to accommodate automation. We help our clients assess automation needs and once a decision is made to proceed, our automation specialists choose the best tools depending on automation objectives and the system under test. Automation takes test cases as input scenarios and is often integrated into a continuous integration process.
Data-driven testing
Keyword-driven Testing
Hybrid Testing
Model-based Testing
Behavior-driven Testing
List of UI Testing Tools
List of Web Testing Tools
Continuous Testing
Test Automation ⚙ Test Strategy and Management 💻 mob/desk📱 Read the full article
Another win for unittesing this week
They found that an important view was missing on certain devices.
Merge conflict saved by unit tests
Earlier today unit tests saved me from botching a merge conflict resolution. Unit tests, they work!
Visualizing Code Coverage with Nose, Gevent, and Duvet
In this post we'll be introducing a few Python related tools that should aid you in day to day development. Anyone using Python 2.7 will benefit from the below.
Gevent is a library for working with Greenlets, which allows python to use async I/O calls. With network heavy applications (databases, apis) gevent can help execute multiple calls in parallel. It's the same model as used by Node.js and nginx, but in general does not expose callbacks to the end user. As a result, gevent'ed code looks very similar to Python code.
Nose is a test runner. It has a great library of available plugins. One of those is Coverage, a great tool written by Ned Batchelder. Unfortunately it doesn't support gevent out of the box. Fortunately, there's a fork which adds gevent support. You can install the gevent enabled version with the following:
pip install git+https://github.com/newbrough/coverage.git
Run your tests. We use a custom test runner, cleverly named bin/nose, which handles some setup (DB tables, elastic search mappings). Nose has an option to generate XML coverage files, but we need the .coverage file, and it seems the only way to generate seems to be to use the coverage utility. We only care about our own modules, which are all under the top level shift namespace.
coverage run --include 'shift/*' bin/nose
Coverage data is saved to .coverage
Great, now we've got our test coverage, ideally we have a way to visualize it. Duvet is a nice tool for exploring your codebase in a color coded manner to quickly understand where your test coverage is lacking.
pip install duvet
Open duvet. It will give you a nice color coded file browser on the left. The code window on the right indicates code paths which are unreachable.
duvet
Here's a screenshot from the pybee site.
Now you can browse through your code to learn what code paths have not been reached through your tests. You can evaluate whether you need to add tests to cover them, or remove them.
py.test: Fixtures statt funcargs
Statt den bisherigen funcargs kann man in py.test ja jetzt sogenannte Fixtures benutzen. Hier mal ein kleines Beispiel aus conftest.py, wo eine solche angelegt wird:
# content of conftest.py import pytest import pymongo @pytest.fixture def db(request): return pymongo.Connection().test
Hier wird also eine Datenbank-Connection aufgebaut.
Scopes
Man kann dabei auch angeben, welchen Scope das Ergebnis haben soll, ob diese Funktion also pro Modul, pro Test oder pro Klasse ausgeführt oder aber wiederverwendet werden soll. Dazu gibt man einfach einen der folgenden Parameter an:
@pytest.fixtures(scope="module")
Weitere Werte wären "function" (default), "cls" oder "session". Man sollte dabei natürlich Seiteneffekte beachten.
Finalizers
In dem obigen Beispiel wäre zudem noch schön, wenn die Datenbank nach jedem Test auch wieder gelöscht oder zumindest auf ein Standard-Setup zurückgeführt würde. Wir können das natürlich einfach in die obige Funktion reinschreiben, schöner jedoch wäre eine Funktion, die das nach dem Lauf des Tests macht. Das geht wie folgt:
@pytest.fixture def db(request): db = pymongo.Connection().test def fin(): db.users.remove() request.addfinalizer(fin) return db
Der Finalizer wird genau dann aufgerufen, wenn der Scope verlassen wird, für den diese Fixture gilt.
Nutzung von Fixtures
Genutzt werden die Fixtures ähnlich wie die funcargs zuvor. Man gibt sie in seiner Testfunktion einfach an:
def test_something(db): db.users.insert({_id: 1}) assert db.users.find_one()['_id'] == 1
Auch andere Fixtures können das benutzen:
@pytest.fixture def app(request, db): return Application(db)
Die von einer Fixture benötigten anderen Fixtures werden also einfach nach dem Request-Paramater aufgelistet. Mehr Info
Wer mehr wissen will, sollte sich das Tutorial oder die API-Dokumentation zu Fixtures ansehen.