Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing: Improve instructions and process #8844 #8978

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .templates/ideaRunConfigurations/CI_Tests.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
</pattern>
</extension>
<module name="" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
<option name="ALTERNATIVE_JRE_PATH" value="1.8" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="SUITE_NAME" value="$PROJECT_DIR$/src/test/testng-ci.xml" />
<option name="PACKAGE_NAME" value="" />
<option name="MAIN_CLASS_NAME" value="" />
Expand All @@ -25,7 +25,7 @@
<option name="TEST_SEARCH_SCOPE">
<value defaultName="wholeProject" />
</option>
<option name="USE_DEFAULT_REPORTERS" value="false" />
<option name="USE_DEFAULT_REPORTERS" value="true" />
<option name="PROPERTIES_FILE" value="" />
<envs />
<properties />
Expand Down
6 changes: 3 additions & 3 deletions .templates/ideaRunConfigurations/Failed_Tests.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<configuration default="false" name="Failed Tests" type="TestNG" factoryName="TestNG">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<module name="" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
<option name="ALTERNATIVE_JRE_PATH" value="1.8" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="SUITE_NAME" value="$PROJECT_DIR$/test-output/testng-failed.xml" />
<option name="PACKAGE_NAME" value="" />
<option name="MAIN_CLASS_NAME" value="" />
Expand All @@ -20,7 +20,7 @@
<option name="TEST_SEARCH_SCOPE">
<value defaultName="wholeProject" />
</option>
<option name="USE_DEFAULT_REPORTERS" value="false" />
<option name="USE_DEFAULT_REPORTERS" value="true" />
<option name="PROPERTIES_FILE" value="" />
<envs />
<properties />
Expand Down
6 changes: 3 additions & 3 deletions .templates/ideaRunConfigurations/Local_Tests.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<configuration default="false" name="Local Tests" type="TestNG" factoryName="TestNG">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<module name="" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
<option name="ALTERNATIVE_JRE_PATH" value="1.8" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="SUITE_NAME" value="$PROJECT_DIR$/src/test/testng-local.xml" />
<option name="PACKAGE_NAME" value="" />
<option name="MAIN_CLASS_NAME" value="" />
Expand All @@ -20,7 +20,7 @@
<option name="TEST_SEARCH_SCOPE">
<value defaultName="wholeProject" />
</option>
<option name="USE_DEFAULT_REPORTERS" value="false" />
<option name="USE_DEFAULT_REPORTERS" value="true" />
<option name="PROPERTIES_FILE" value="" />
<envs />
<properties />
Expand Down
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ dist: trusty

addons:
firefox: "46.0"
apt:
packages:
- language-pack-de

before_install:
- |
Expand All @@ -28,6 +31,9 @@ before_install:
- "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid \
--make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1440x900x16"
- nvm install node
- export LANG=de_DE.UTF-8
- export LC_ALL=de_DE.UTF-8
- locale

before_script:
- export DISPLAY=:99.0
Expand Down
2 changes: 1 addition & 1 deletion docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ Before running tests, modify `src/test/resources/test.properties` if necessary,

### Using Firefox

* Only Firefox between versions 38.0.5 and 46.0.1 are supported.
* Only Firefox between versions 38.0.5 and 46.0.0 are supported.
* To downgrade your Firefox version, obtain the executable from [here](https://ftp.mozilla.org/pub/mozilla.org/firefox/releases/).
* 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`).
Expand Down
3 changes: 3 additions & 0 deletions gradle.template.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ org.gradle.daemon=false
# e.g org.gradle.java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home
# e.g org.gradle.java.home=C:/Program Files/Java/jdk1.8.0_144
# org.gradle.java.home=

# The test environment REQUIRES the following locale. Do not change!
org.gradle.jvmargs=-Duser.language=en -Duser.country=US
10 changes: 10 additions & 0 deletions src/test/java/teammates/test/cases/BaseTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
import java.io.IOException;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Locale;

import org.junit.Assert;
import org.testng.AssertJUnit;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeSuite;

import teammates.common.datatransfer.DataBundle;
import teammates.common.util.FieldValidator;
Expand Down Expand Up @@ -38,6 +40,14 @@ public static void ______TS(String description) {
}
// CHECKSTYLE.ON:AbbreviationAsWordInName|MethodName

/**
* Set the required locale for tests.
*/
@BeforeSuite
public void setLocale() {
Locale.setDefault(new Locale("en", "US"));
}

@BeforeClass
public void printTestClassHeader() {
print("[============================="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.net.MalformedURLException;
import java.net.URL;
import java.util.Locale;

import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
Expand All @@ -21,15 +22,17 @@ public class BaseTestCaseWithMinimalGaeEnvironment extends BaseTestCase {
private LocalServiceTestHelper helper = new LocalServiceTestHelper();

/**
* Sets the environment of SystemProperty based on the URL.
* Sets the environment of SystemProperty based on the URL and default locale required for tests.
*/
@BeforeSuite
public void setUpEnvironment() throws MalformedURLException {
public void setUpEnvironmentAndLocale() throws MalformedURLException {
if (new URL(TestProperties.TEAMMATES_URL).getHost().contains(".appspot.com")) {
SystemProperty.environment.set(SystemProperty.Environment.Value.Production);
} else {
SystemProperty.environment.set(SystemProperty.Environment.Value.Development);
}

Locale.setDefault(new Locale("en", "US"));
}

@BeforeClass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.google.appengine.api.datastore.Text;

import teammates.common.datatransfer.attributes.StudentProfileAttributes;
import teammates.common.util.Const;
import teammates.common.util.FieldValidator;
import teammates.common.util.SanitizationHelper;
import teammates.common.util.TimeHelper;
Expand Down Expand Up @@ -178,6 +179,10 @@ public void testToEntity() {
StudentProfileAttributes testProfile = StudentProfileAttributes.valueOf(expectedEntity);
StudentProfile actualEntity = testProfile.toEntity();

// toEntity does not use the original modified date so we need to ensure they are the same
expectedEntity.setModifiedDate(Const.TIME_REPRESENTS_DEFAULT_TIMESTAMP);
actualEntity.setModifiedDate(Const.TIME_REPRESENTS_DEFAULT_TIMESTAMP);

assertEquals(expectedEntity.getShortName(), actualEntity.getShortName());
assertEquals(expectedEntity.getInstitute(), actualEntity.getInstitute());
assertEquals(expectedEntity.getEmail(), actualEntity.getEmail());
Expand Down
1 change: 1 addition & 0 deletions src/test/java/teammates/test/pageobjects/Browser.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ private WebDriver createWebDriver() {

ChromeOptions options = new ChromeOptions();
options.addArguments("--allow-file-access-from-files");
options.addArguments("--lang=en-us");
return new ChromeDriver(options);
}
System.out.println("Using " + browser + " is not supported!");
Expand Down