CooperativeIT / testing

A repo for collecting tests
GNU General Public License v3.0
0 stars 0 forks source link

Binlgeymusictown branch - local and live tests #64

Open caprenter opened 12 months ago

caprenter commented 12 months ago

This is on the binlgeymusictown branch

We added a profile to behat.yml yesterday so that we can run

behat --profile=local --tags @header_menu to test our local development site

and

behatl --tags @header_menu

would run the live site out on the web

This is just using the live.testing docker-compose

If I run jekyll locally, it serves a site on 127.0.0.1:4000 - so I want that local profile to 'go there' and I'm not sure how I map it so that behat knows where to find it without also stopping it from going to the web when it should!

caprenter commented 12 months ago

@plebster - if you wanted to investigate you might be able to do this with anything on port 4000, not just jekyll or whatevs!

I can't do anything today really.

Plebster commented 12 months ago

couple of things...

firstly this needs a really good tidy up, main is essentially lamrt testing, it took a while to know what to remove so I could run a basic test.

When running against a local running docker site, wordpress in my instance, you need to do the following(I was just using live docker compose):

  1. add the testing docker-compose to the the same docker network as the wordpress docker, I did this for both Behat and selenium although didn't test selenium.
  2. extract the ip address of the wordpress docker container. docker inspect wordpress | grep "IPAddress"
  3. enter this ip address into your behat.yml, I did it in my extended profile section

I had this working against both an external and local site

caprenter commented 11 months ago

Cool - so what I think you have just described is what the create_hosts script was doing previously.

Get everything on the same network and specify the ip address of the local container you want to test (- although this was so that the hosts file could redirect the bass url - which is great as long as you don't also want to test live)

Now that we have profiles it allows for e.g. https and ports to be specified in the various url paths - so that's great.

So I think I'm seeing that for my Bingley music town case, I might write a docker compose yml file that brings up all 3 containers o on the same network (behat, selenium, and jekyll)

There would then be a manual step to rewrite the base url in the behat.yml local profile - seems like we could script that (in the docker-compose? I'm thinking that although we might wan this for jekyll ,or wordpress or drupal -actually we do want it for specific named sites,and want it to just work if possible.)

Plebster commented 11 months ago

yep, pretty much the same as the script. does Jekyll lock you to a url like wordpress, if not then you can just use the url. If that is the case we could just extend the script to check multiple containers and extract their ips.

I think that maybe this needs to be pulled into each projects git rather and have a clean testing repo rather than various branches.

Plebster commented 11 months ago

maybe due to the high initial overhead of setting this uo this should be part of our project initiation. then it is there for us all to in one project repo