These are the common tasks involved when working on features, enhancements, bug fixes, etc. for TEAMMATES.
- Building JavaScript files
- Managing the dev server
- Logging in to a TEAMMATES instance
- Testing
- Deploying to a staging server
- Running client scripts
- Config points
The instructions in all parts of this document work for Linux, OS X, and Windows, with the following pointers:
- Replace
./gradlew
togradlew.bat
if you are using Windows. - All the commands are assumed to be run from the root project folder, unless otherwise specified.
- It is assumed that the development environment has been correctly set up. If this step has not been completed, refer to this document.
If you encounter any problems during the any of the processes, please refer to our troubleshooting guide before posting a help request on our issue tracker.
Our JavaScript code is written in ECMAScript 6 (ES6) syntax, however many of the existing Web browsers today still have limited support for ES6.
To resolve this, we need to transpile ("build" afterwards) these JavaScript files into ECMAScript 5 syntax which is supported by (almost) all browsers.
Run the following command to build the JavaScript files for the application's use:
npm run build
Dev server
is the server run in your local machine.
- Change the value of
org.gradle.daemon
ingradle.properties
totrue
.
Run the following command:
./gradlew appengineRun
Wait until the task exits with a BUILD SUCCESSFUL
.
The dev server URL will be http://localhost:8888
as specified in build.gradle
.
Run the following command:
./gradlew appengineStop
Right-click on the project folder and choose Run As → Web Application
.
After some time, you should see this message (or similar) on the Eclipse console: Dev App Server is now running
.
The dev server URL will be given at the console output, e.g http://localhost:8888
.
Click the "Terminate" icon on the Eclipse console.
If this is your first time running the dev server, you will need to set up the required
Run Configuration
.
- Go to
File → Project Structure...
. - Under
Artifacts → Gradle : <your-project-name>.war (exploded)
, checkInclude in project build
. - Click
OK
. - Go to
Run → Edit Configurations...
. - Click
+ → Google AppEngine Dev Server
. - Set the
Name:
toDev Server
. - Ensure the
Application server:
selected is of the nameAppEngine Dev <version>
.
If you do not have an application server namedAppEngine Dev <version>
, make sure you have setup IntelliJ IDEA correctly. - You can optionally choose to add
-Ddatastore.backing_store=../../../../local_db.bin
toVM options:
.
This will place your local datastore on your project root, and if you delete yourbuildIdea
folder your local datastore will still be preserved. Note that IntelliJ IDEA does not delete the wholebuildIdea
folder on rebuild so your datastore will not be wiped on rebuild. - If you have a previous datastore file
local_db.bin
that you would like to use, you can copy it to the project root if you have changed the datastore path in the previous step. Otherwise, you would need to check theOutput directory:
ofGradle : teammates.war (exploded)
fromFile → Project Structure... → Artifacts
, copylocal_db.bin
into<OutputDirYouFound>/WEB-INF/appengine-generated
(create the folder if it does not exist). - If you do not want the app to auto launch on the browser, under
Open browser
, uncheckAfter launch
. - Check in
JRE:
that the SDK used is the default of1.7
.
Otherwise your project might not have been configured correctly, please check your setup. - Set the
Port:
to8888
. - Click
OK
.
Go to Run → Run...
and select Dev Server
in the pop-up box.
Go to Run → Stop
.
This instruction set applies for both dev server and production server, with slight differences explained where applicable.
- The local dev server is assumed to be accessible at
http://localhost:8888
. - If a URL is given as relative, prepend the server URL to access the page, e.g
/page/somePage
is accessible in dev server athttp://localhost:8888/page/somePage
.
- Go to any administrator page, e.g
/admin/adminHomePage
. - On the dev server, log in using any username, but remember to check the
Log in as administrator
check box. You will have the required access. - On the production server, you will be granted the access only if your account has administrator permission to the application.
You need an instructor account which can be created by administrators.
- Log in to
/admin/adminHomePage
as an administrator. - Enter credentials for an instructor, e.g
Short Name:Instructor
Name:John Dorian
Email:teammates.instructor@university.edu
Institution:National University of Singapore
- The system will send an email containing the join link to the added instructor.
On the dev server, this email will not be sent. Instead, you can use the join link given after adding an instructor to complete the joining process.
Remember to change the base URL of the link if necessary, but keep the parameters,
e.g changehttps://teammates-john.appspot.com
/page/instructorCourseJoin?key=F2AD69F8994BA92C8D605BAEDB35949A41E71A573721C8D60521776714DE0BF8B0860F12DD19C6B955F735D8FBD0D289&instructorinstitution=NUS
tohttp://localhost:8888
/page/instructorCourseJoin?key=F2AD69F8994BA92C8D605BAEDB35949A41E71A573721C8D60521776714DE0BF8B0860F12DD19C6B955F735D8FBD0D289&instructorinstitution=NUS
You need a student account which can be created by instructors.
- Log in as an instructor. Add a course for yourself and then add the students for the course.
- The system will send an email containing the join link to each added student. Again, this will not happen on the dev server, so additional steps are required.
- Log out and log in to
http://localhost:8888/admin/adminSearchPage
as administrator. - Search for the student you added in as instructor. From the search results, click anywhere on the desired row (except on the student name) to get the course join link for that student.
- Log out and use that join link (again, change the base URL to
http://localhost:8888
if necessary) to log in as a student.
Alternative: Run the test cases, they create several student and instructor accounts in the datastore. Use one of them to log in.
TEAMMATES automated testing requires Firefox or Chrome (works on Windows and OS X). It is recommended to use Firefox 46.0 as this is the browser used in CI build (Travis/AppVeyor).
Before running the test suite, both the server and the test environment should be using the UTC time zone. If this has not been done yet, here is the procedure:
- Stop the dev server if it is running.
- Specify timezone as a VM argument:
- Eclipse
- Go to the run configuration Eclipse created when you started the dev server (
Run → Run configurations ...
and select the appropriate one). - Click on the
Arguments
tab and add-Duser.timezone=UTC
to theVM arguments
text box. - Save the configuration for future use: Go to the
Common
tab (the last one) and make sure you have selectedSave as → Local file
andDisplay in favorites menu → Run, Debug
.
- Go to the run configuration Eclipse created when you started the dev server (
- IntelliJ
- Go to
Run → Edit Configurations...
and selectDev Server
. - Add
-Duser.timezone=UTC
to theVM options
text box. ClickOK
.
- Go to
- Eclipse
- Start the server again using the run configuration you created in the previous step.
-
Only Firefox between versions 38.0.5 and 46.0.1 are supported.
- To downgrade your Firefox version, obtain the executable from here.
- If you want to use a different path for this version, choose
Custom setup
during install. - Remember to disable the auto-updates (
Options → Advanced tab → Update
).
-
If you want to use a Firefox version other than your computer's default, specify the custom path in
test.firefox.path
value intest.properties
. -
If you are planning to test changes to JavaScript code, disable JavaScript caching for Firefox:
- Enter
about:config
into the Firefox address bar and setnetwork.http.use-cache = false
.
- Enter
-
You need to use chromedriver for testing with Chrome.
- Download the latest stable chromedriver from here. The site will also inform the versions of Chrome that can be used with the driver.
- Specify the path to the chromedriver executable in
test.chromedriver.path
value intest.properties
.
-
If you are planning to test changes to JavaScript code, disable JavaScript caching for Chrome:
- Press Ctrl+Shift+J to bring up the Web Console.
- Click on the settings button at the bottom right corner.
- Under the General tab, check "Disable Cache".
-
The chromedriver process started by the test suite will not automatically get killed after the tests have finished executing.
You will need to manually kill these processes after the tests are done.- On Windows, use the Task Manager or
taskkill /f /im chromedriver.exe
command. - On OS X, use the Activity Monitor or
sudo killall chromedriver
command.
- On Windows, use the Task Manager or
Several configurations are provided by default:
CI tests
- Runssrc/test/testng-ci.xml
, all the tests that are run by CI (Travis/AppVeyor).Local tests
- Runssrc/test/testng-local.xml
, all the tests that need to be run locally by developers.Dev green
means passing all the tests in this configuration.Failed tests
- Runstest-output/testng-failed.xml
, which is generated if a test run results in some failures. This will run only the failed tests.
Before running any test suite, it is important to have the dev server running locally first if you are testing against it.
Test suite | Command | Results can be viewed in |
---|---|---|
CI tests |
./gradlew ciTests |
{project folder}/build/reports/test-try-{n}/index.html , where {n} is the sequence number of the test run |
Local tests |
./gradlew localTests |
{project folder}/build/reports/test-local/index.html |
Failed tests |
./gradlew failedTests |
{project folder}/build/reports/test-failed/index.html |
Any individual test | ./gradlew test -Dtest.single=TestClassName |
{project folder}/build/reports/tests/index.html |
CI tests
will be run once and the failed tests will be re-run a few times.
All other test suites will be run once and only once.
To run any test suite or individual test with GodMode turned on, set the value of test.godmode.enabled
to true
in test.properties
.
- An additional configuration
All tests
is provided, which will runCI tests
andLocal tests
. - Additionally, configurations that run the tests with
GodMode
turned on are also provided. - When running the test cases, if a few cases fail (this can happen due to timing issues), re-run the failed cases using the
Run Failed Test
icon in the TestNG tab until they pass.
Run tests using the configurations available under the green Run
button on the Eclipse toolbar.
Sometimes, Eclipse does not show these options immediately after you set up the project. "Refreshing" the project should fix that.
To run individual tests, right-click on the test files on the project explorer and choose Run As → TestNG Test
.
Run tests using the configurations available under Run → Run...
.
To run individual tests, right-click on the test files on the project explorer and choose Run
.
Staging server
is the server instance you set up on Google App Engine for hosting the app for testing purposes.
This instruction set assumes that the app identifier is teammates-john
.
-
Create your own app on GAE.
Suggested app identifier:teammates-yourname
(e.gteammates-john
).
The URL of the app will be like this:https://teammates-john.appspot.com
. -
Modify configuration files.
src/main/resources/build.properties
Edit the file as instructed in its comments.src/main/webapp/WEB-INF/appengine-web.xml
Modify to match app name and app id of your own app, and the version number if you need to. Do not modify anything else.
-
Deploy the application to your staging server.
- With command line
-
Run the following command:
./gradlew appengineUpdate
-
Follow the steps and wait until the command ends with a
BUILD SUCCESSFUL
.
-
- With Eclipse
- Choose
Deploy to App Engine...
from Eclipse (under theGoogle
menu item) and follow the steps. - Wait until you see this message (or similar) in Eclipse console:
Deployment completed successfully
.
- Choose
- With IntelliJ
- Refer to this guide to deploy your application.
- With command line
-
(Optional) Set the version you deployed as the "default":
- Go to App Engine dashboard:
https://console.cloud.google.com/appengine?project=teammates-john
. - Click
Versions
underMain
menu on the left bar. - Tick the checkbox next to the deployed version and select
Migrate Traffic
. Wait for a few minutes. - If you do not wish to set the deployed version as the default, you can access the deployed app using
https://{version}-dot-teammates-john.appspot.com
, e.ghttps://4-18-dot-teammates-john.appspot.com
.
- Go to App Engine dashboard:
-
(Optional) You can run the tests against the deployed app.
- Edit
src/test/resources/test.properties
as instructed is in its comments. - Run the full test suite or any subset of it as how you would have done it in dev server. However, the GAE daily quota is usually not enough to run the full test suite, in particular for accounts with no billing enabled.
- Edit
Client scripts are scripts that remotely manipulate data on GAE via its Remote API. They are run as standard Java applications.
Most of developers may not need to write and/or run client scripts but if you are to do so in a production environment, additional steps are required:
- Download and install Google Cloud SDK from here.
- Run
gcloud auth login
and choose your Google account for authentication.
You are now ready to run your scripts.
There are several files used to configure various aspects of the system.
Main: These vary from developer to developer and are subjected to frequent changes.
build.properties
: Contains the general purpose configuration values to used by the web app.test.properties
: Contains the configuration values for the test driver.appengine-web.xml
: Contains the configuration for deploying the application on GAE.
Tasks: These do not concern the application directly, but rather the development process.
build.gradle
: Contains the server-side third-party dependencies specification, as well as configurations for automated tasks/routines to be run via Gradle.gradle.properties
,gradle-wrapper.properties
: Contains the Gradle and Gradle wrapper configuration.package.json
: Contains the client-side third-party dependencies specification..travis.yml
: Contains the Travis CI job configuration.appveyor.yml
: Contains the AppVeyor CI job configuration.
Static Analysis: These are used to maintain code quality and measure code coverage. See Static Analysis.
static-analysis/*
: Contains most of the configuration files for all the different static analysis tools..stylelintrc
: Equivalent tostatic-analysis/teammates-stylelint.yml
, currently only used for Stylelint integration in IntelliJ.
Other: These are rarely, if ever will be, subjected to changes.
logging.properties
: Contains the java.util.logging configuration.log4j.properties
: Contains the log4j configuration. Not used by us.web.xml
: Contains the web server configuration, e.g servlets to run, mapping from URLs to servlets/JSPs, security constraints, etc.cron.xml
: Contains the cron jobs specification.queue.xml
: Contains the task queues configuration.jdoconfig.xml
: Contains the JDO configuration.persistence.xml
: Contains the JPA configuration.