I have two test files.
One is standard TestCases. The other has selenium tests in it. I have a docker-compose file setup to run the selenium tests with their associated services.
The tests run in bitbucket-pipelines. First it runs the test with the standard TestCases. Then in the next step it uses docker-compose to run the tests that include selenium since it needs compose to set up the selenium services.
The issue I'm having is it's trying to run the selenium tests during the first step when there isn't any selenium containers running.
I entered this in my Django settings file used for the first testing part:
NOSE_ARGS = [
'--exclude=(__init__.py)',
'--exclude=(../tests/selenium_tests.py)',
'--exclude=(selenium_tests.py)',
'--with-coverage',
'--cover-package=sasite',
'--with-xunit',
'--xunit-file=test-results/nose/noseresults.xml',
'--verbosity=3',
'--cover-xml',
'--cover-xml-file=test-results/nose/noseresults.xml',
'--id-file=test-results/nose/noseids'
]
and in my settings for the second:
NOSE_ARGS = [
'--exclude=(__init__.py)',
'--with-coverage',
'--cover-package=sasite',
'--with-xunit',
'--xunit-file=test-results/nose/noseresults.xml',
'--verbosity=3',
'--cover-xml',
'--cover-xml-file=test-results/nose/noseresults.xml',
'--id-file=test-results/nose/noseids'
]
As you can see, I want to exclude the selenium tests for the first part, and use them for the second. But even with my exclude in nose_args it still runs the selenium tests in the first part.
Here is my bitbucket-pipelines.yml:
prod-final:
- step:
name: Build image, run tests, and push to Docker Hub
caches:
- docker
services:
- docker
script:
# Set $DOCKER_HUB_USERNAME and $DOCKER_HUB_PASSWORD as environment variables in repository settings
- export DOCKER_HUB_USERNAME=X
- export DOCKER_HUB_PASSWORD=XXX
# build the Docker image (this will use the Dockerfile in the root of the repo)
- docker build -t meleiyu/sawebsite-redesign -f Dockerfile.imagetest .
# run tests
- docker run meleiyu/sawebsite-redesign
# tag Docker image
- docker tag meleiyu/sawebsite-redesign meleiyu/sawebsite-redesign:latest
# authenticate with the Docker Hub registry
- docker login --username $DOCKER_HUB_USERNAME --password $DOCKER_HUB_PASSWORD
# push the new Docker image to the Docker registry
- docker push meleiyu/sawebsite-redesign:latest
- step:
name: Run second level of testing with BrowserStack
image: docker:stable
trigger: manual
caches:
- docker
services:
- docker
script:
# Test production setup with compose
- apk add --no-cache py-pip bash
- pip install --no-cache docker-compose
- docker-compose -f docker-compose.test.yml up -d --build --exit-code-from app
- step:
# set AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_DEFAULT_REGION as environment variables
name: Deploy to AWS
deployment: staging # set to test, staging or production
trigger: manual # uncomment to have a manual step
image: atlassian/pipelines-awscli
script:
- aws deploy push --application-name sawebsite-redesign --s3-location s3://<S3 bucket>/<s3-key> --ignore-hidden-files
- aws deploy create-deployment --application-name sawebsite-redesign --s3-location bucket=<s3-bucket>,key=<s3-key>,bundleType=zip --deployment-group-name <deployment-group>
definitions:
services:
docker:
memory: 3072
Dockerfile.imagetest is for the first part, and has the settings to exclude selenium tests file.
Dockerfile.test and docker-compose.test.yml are for the second part and don't exclude the selenium tests file.
Does my config/setup make sense?? Am I excluding the files correctly in nose_args? Because as I said it's running the selenium tests in part one when it shouldn't be doing so.
Any input would be appreciated.
Thanks
EDIT:
My NOSE_ARGS now:
To not ignore any tests:
NOSE_ARGS = [
'--exclude=(__init__.py)',
'--with-coverage',
'--cover-package=sasite',
'--with-xunit',
'--xunit-file=test-results/nose/noseresults.xml',
'--verbosity=3',
'--cover-xml',
'--cover-xml-file=test-results/nose/noseresults.xml',
'--id-file=test-results/nose/noseids'
]
To exclude selenium tests:
NOSE_ARGS = [
'--exclude=(__init__.py)',
'--exclude=(../tests/selenium_tests.py)',
'--exclude=(selenium_tests.py)',
'--ignore=(selenium_tests.py)',
'--ignore=(../tests/selenium_tests.py)',
'--ignore-files=../tests/selenium_tests.py',
'--ignore-files=selenium_tests.py',
'--with-coverage',
'--cover-package=sasite',
'--with-xunit',
'--xunit-file=test-results/nose/noseresults.xml',
'--verbosity=3',
'--cover-xml',
'--cover-xml-file=test-results/nose/noseresults.xml',
'--id-file=test-results/nose/noseids'
]