Actions

Difference between revisions of "Testing Area/Behat Testing/Setup"

From Mahara Wiki

< Testing Area‎ | Behat Testing
Line 1: Line 1:
 
=How to install Mahara and Behat=
 
=How to install Mahara and Behat=
  
'''Note''': These instructions for Mahara and Behat setup are only for machines running Linux. They will not work for Windows machines
+
'''Note''': These instructions for Mahara and Behat setup are only for machines running Linux. They will not work for Windows machines.
  
 +
1. Set up your [[Developer_Area/Developer_Environment | developer environment]] if you haven't already done so.
  
 +
2. Install Behat's dependencies:
 +
<source lang="bash" enclose="div">
 +
$ sudo apt-get install curl openjdk-7-jre-headless
 +
</source>
  
== For dev's instructions to install a Mahara ==
+
3. Add the following config settings to the bottom of your Mahara config.php file inside the htdocs/ subdirectory of the Mahara codebase.  
Please use [[System_Administrator%27s_Guide/Installing_Mahara]].
 
 
 
 
 
 
 
== Otherwise, if you do not have Mahara installed ==
 
 
 
[[Developer_Area/Developer_Environment | Follow the instructions]] for setting up Mahara.
 
 
 
{{note|If you do have Mahara already installed, skip to [[#Behat_installation]]}}
 
 
 
 
 
===Behat installation===
 
 
 
Install Behat's dependencies:
 
sudo apt-get install curl openjdk-7-jre-headless
 
 
 
Add these config settings to the bottom of your Mahara config.php file, inside the htdocs/ subdirectory of the Mahara codebase.  
 
  
 
{{note|If /var/www/maharadata is not where you created your dataroot, you'll need to replace that with the correct path in the following commands}}
 
{{note|If /var/www/maharadata is not where you created your dataroot, you'll need to replace that with the correct path in the following commands}}
  
<pre>
+
<source lang="bash" enclose="div">
 
// Behat config
 
// Behat config
$cfg->dbprefix = ''; // Behat complains without dbprefix being set
 
$cfg->wwwroot = 'http://your.mahara.domain/';  // Add this if you do not have wwwroot set already, Behat complains with out it
 
 
$cfg->behat_dbprefix = 'behat_'; // must not empty
 
$cfg->behat_dbprefix = 'behat_'; // must not empty
$cfg->behat_dataroot = "/var/lib/maharadata/behat"; // Behat's copy of mahara data
+
$cfg->behat_dataroot = "/var/lib/maharadata/master_behat"; // Behat's copy of maharadata
 
$cfg->behat_wwwroot = 'http://localhost:8000'; // Must be this
 
$cfg->behat_wwwroot = 'http://localhost:8000'; // Must be this
</pre>
+
</source>
 +
 
 +
{{note|There should be a behat_dataroot for each Mahara instance that you set up. Here the one for the master branch / this Mahara instance is created.
  
Make your data directory (check this matches what you set in config.php):
+
4. Make your Behat data directory (check this matches what you set in config.php):
sudo mkdir /var/lib/maharadata/behat
+
<source lang="bash" enclose="div">
 +
$ sudo mkdir /var/lib/maharadata/master_behat
 +
</source>
  
Make directory writeable by mahara (check this is correct):  
+
5. Make the directory writeable by Mahara (check this is correct):  
sudo chmod 777 /var/lib/maharadata/behat
+
<source lang="bash" enclose="div">
 +
$ sudo chmod 777 /var/lib/maharadata/behat
 +
</source>
  
Run Behat tests (change into your Mahara code directory first)
+
6. Run Behat tests (change into your Mahara code directory first):
./test/behat/mahara_behat.sh run
+
<source lang="bash" enclose="div">
 +
$ cd
 +
$ cd code/mahara
 +
./test/behat/mahara_behat.sh run
 +
</source>
  
For the first time of running behat, you need to wait for the Behat environment initialisation. This can take a while.
+
For the first time of running Behat, you need to wait for the Behat environment initialisation. This can take a while.
  
To run all tests
+
To run all tests:
 
  ./test/behat/mahara_behat.sh run
 
  ./test/behat/mahara_behat.sh run
  

Revision as of 08:04, 12 July 2015

How to install Mahara and Behat

Note: These instructions for Mahara and Behat setup are only for machines running Linux. They will not work for Windows machines.

1. Set up your developer environment if you haven't already done so.

2. Install Behat's dependencies:

$ sudo apt-get install curl openjdk-7-jre-headless

3. Add the following config settings to the bottom of your Mahara config.php file inside the htdocs/ subdirectory of the Mahara codebase.

Note: If /var/www/maharadata is not where you created your dataroot, you'll need to replace that with the correct path in the following commands
// Behat config
$cfg->behat_dbprefix = 'behat_'; // must not empty
$cfg->behat_dataroot = "/var/lib/maharadata/master_behat"; // Behat's copy of maharadata
$cfg->behat_wwwroot = 'http://localhost:8000'; // Must be this

{{note|There should be a behat_dataroot for each Mahara instance that you set up. Here the one for the master branch / this Mahara instance is created.

4. Make your Behat data directory (check this matches what you set in config.php):

$ sudo mkdir /var/lib/maharadata/master_behat

5. Make the directory writeable by Mahara (check this is correct):

$ sudo chmod 777 /var/lib/maharadata/behat

6. Run Behat tests (change into your Mahara code directory first):

$ cd
$ cd code/mahara
./test/behat/mahara_behat.sh run

For the first time of running Behat, you need to wait for the Behat environment initialisation. This can take a while.

To run all tests:

./test/behat/mahara_behat.sh run

To run your specific tests:

./test/behat/mahara_behat.sh run @yourtags