JUnit: Parameterized Tests and Theory Tests

JUnit tests with parameterized tests


Configure Jenkins for a Basic Python Project

Install and set up Jenkins following the official document.

Plugins: Install Jenkins Covertura Plugin + GIT Plugin + Jenkins Violations.

Step 1: Create a new Item “py_analysis” and select “Build a free-style software project”

Step 2: Version Control. I put Git here, with repo URL and credential. I added “SSH username with private key” here. The category of credential may vary depending on users’ situation.

Step 3: Add build step – Execute shell


# Delete previously built virtualenv
#if [ -d $PYENV_HOME ]; then
#    rm -rf $PYENV_HOME

# Create virtualenv and install necessary packages
virtualenv $PYENV_HOME
. $PYENV_HOME/bin/activate
pip install --quiet <LIBS I LOVE>
pip install --quiet pylint
pip install --quiet $WORKSPACE/project/  # where your setup.py lives
#nosetests --with-xcoverage --with-xunit --cover-package=model --cover-erase
cd $WORKSPACE/project/testPackage 
nosetests --with-xunit --cover-package=model --cover-erase -a '!slow'
pylint -f parseable $WORKSPACE/project/package | tee pylint.out

Step 4: Post-build Actions
Publish Covertura Coverage Report – Put Covertura xml report pattern as “**/coverage.xml”

Publish Unit Test Report – Put Covertura xml report pattern as “**/nosetest.xml”

Step 5: Save and build.

reference: http://bhfsteve.blogspot.ie/2012/04/automated-python-unit-testing-code_27.html