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

[#8844] Testing: Improve instructions and process #8988

Closed
wants to merge 8 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
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package teammates.common.datatransfer.questions;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
Expand All @@ -20,6 +19,7 @@
import teammates.common.util.HttpRequestHelper;
import teammates.common.util.SanitizationHelper;
import teammates.common.util.StringHelper;
import teammates.common.util.TeammatesDecimalFormat;
import teammates.common.util.Templates;
import teammates.common.util.Templates.FeedbackQuestion.FormTemplates;
import teammates.common.util.Templates.FeedbackQuestion.Slots;
Expand Down Expand Up @@ -447,8 +447,6 @@ public String getQuestionResultStatisticsHtml(

Map<String, List<Integer>> optionPoints = generateOptionPointsMapping(responses);

DecimalFormat df = new DecimalFormat("#.##");

Map<String, List<Integer>> sortedOptionPoints = new TreeMap<>();

Map<String, String> identifierMap = new HashMap<>();
Expand All @@ -475,14 +473,14 @@ public String getQuestionResultStatisticsHtml(
Slots.TEAM, SanitizationHelper.sanitizeForHtml(teamName),
Slots.CONSTSUM_POINTS_RECEIVED, pointsReceived,
Slots.CONSTSUM_TOTAL_POINTS, Integer.toString(total),
Slots.CONSTSUM_AVERAGE_POINTS, df.format(average)));
Slots.CONSTSUM_AVERAGE_POINTS, TeammatesDecimalFormat.format(average, "#.##")));
} else {

fragments.append(Templates.populateTemplate(FormTemplates.CONSTSUM_RESULT_STATS_OPTIONFRAGMENT,
Slots.CONSTSUM_OPTION_VALUE, SanitizationHelper.sanitizeForHtml(option),
Slots.CONSTSUM_POINTS_RECEIVED, pointsReceived,
Slots.CONSTSUM_TOTAL_POINTS, Integer.toString(total),
Slots.CONSTSUM_AVERAGE_POINTS, df.format(average)));
Slots.CONSTSUM_AVERAGE_POINTS, TeammatesDecimalFormat.format(average, "#.##")));
}
});

Expand All @@ -509,8 +507,6 @@ public String getQuestionResultStatisticsCsv(
List<String> options = constSumOptions;
Map<String, List<Integer>> optionPoints = generateOptionPointsMapping(responses);

DecimalFormat df = new DecimalFormat("#.##");

Map<String, List<Integer>> sortedOptionPoints = new TreeMap<>();

Map<String, String> identifierMap = new HashMap<>();
Expand Down Expand Up @@ -538,8 +534,8 @@ public String getQuestionResultStatisticsCsv(
double total = computeTotal(points);

fragments.append(option)
.append(',').append(df.format(average))
.append(',').append(df.format(total))
.append(',').append(TeammatesDecimalFormat.format(average, "#.##"))
.append(',').append(TeammatesDecimalFormat.format(total, "#.##"))
.append(',').append(StringHelper.join(",", points))
.append(System.lineSeparator());

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package teammates.common.datatransfer.questions;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.LinkedHashMap;
Expand All @@ -21,6 +20,7 @@
import teammates.common.util.HttpRequestHelper;
import teammates.common.util.Logger;
import teammates.common.util.SanitizationHelper;
import teammates.common.util.TeammatesDecimalFormat;
import teammates.common.util.Templates;
import teammates.common.util.Templates.FeedbackQuestion.FormTemplates;
import teammates.common.util.Templates.FeedbackQuestion.Slots;
Expand Down Expand Up @@ -385,7 +385,6 @@ private List<String> generateOptionList(String courseId) {
public String getQuestionSpecificEditFormHtml(int questionNumber) {
StringBuilder optionListHtml = new StringBuilder();
String optionFragmentTemplate = FormTemplates.MCQ_EDIT_FORM_OPTIONFRAGMENT;
DecimalFormat weightFormat = new DecimalFormat("#.##");

// Create MCQ options
for (int i = 0; i < numOfMcqChoices; i++) {
Expand All @@ -406,13 +405,15 @@ public String getQuestionSpecificEditFormHtml(int questionNumber) {
Templates.populateTemplate(weightFragmentTemplate,
Slots.QUESTION_NUMBER, Integer.toString(questionNumber),
Slots.ITERATOR, Integer.toString(i),
Slots.MCQ_WEIGHT, hasAssignedWeights ? weightFormat.format(mcqWeights.get(i)) : "0",
Slots.MCQ_WEIGHT, hasAssignedWeights
? TeammatesDecimalFormat.format(mcqWeights.get(i), "#.##") : "0",
Slots.MCQ_PARAM_WEIGHT, Const.ParamsNames.FEEDBACK_QUESTION_MCQ_WEIGHT);
weightFragmentHtml.append(weightFragment).append(System.lineSeparator());
}

// Create MCQ other weight value
String mcqOtherWeightValue = hasAssignedWeights && otherEnabled ? weightFormat.format(mcqOtherWeight) : "0";
String mcqOtherWeightValue = hasAssignedWeights && otherEnabled
? TeammatesDecimalFormat.format(mcqOtherWeight, "#.##") : "0";

return Templates.populateTemplate(
FormTemplates.MCQ_EDIT_FORM,
Expand Down Expand Up @@ -522,25 +523,24 @@ public String getQuestionResultStatisticsHtml(List<FeedbackResponseAttributes> r
hasAssignedWeights ? mcqStats.calculateWeightedPercentagePerOption(answerFrequency)
: new LinkedHashMap<>();

DecimalFormat df = new DecimalFormat("#.##");

for (String key : answerFrequency.keySet()) {
int count = answerFrequency.get(key);
// If weights are allowed, show the corresponding weights of a choice.
String weightString = "";
if ("Other".equals(key)) {
weightString = hasAssignedWeights ? df.format(mcqOtherWeight) : "-";
weightString = hasAssignedWeights ? TeammatesDecimalFormat.format(mcqOtherWeight, "#.##") : "-";
} else {
weightString = hasAssignedWeights ? df.format(mcqWeights.get(mcqChoices.indexOf(key))) : "-";
weightString = hasAssignedWeights
? TeammatesDecimalFormat.format(mcqWeights.get(mcqChoices.indexOf(key)), "#.##") : "-";
}

responseSummaryFragments.append(Templates.populateTemplate(FormTemplates.MCQ_RESULT_STATS_OPTIONFRAGMENT,
Slots.MCQ_CHOICE_VALUE, SanitizationHelper.sanitizeForHtml(key),
Slots.MCQ_WEIGHT, weightString,
Slots.COUNT, Integer.toString(count),
Slots.PERCENTAGE, df.format(100 * (double) count / responses.size()),
Slots.WEIGHTED_PERCENTAGE,
hasAssignedWeights ? df.format(weightedPercentagePerOption.get(key)) : "-"));
Slots.PERCENTAGE, TeammatesDecimalFormat.format(100 * (double) count / responses.size(), "#.##"),
Slots.WEIGHTED_PERCENTAGE, hasAssignedWeights
? TeammatesDecimalFormat.format(weightedPercentagePerOption.get(key), "#.##") : "-"));
}

// If weights are assigned, create the per recipient statistics table,
Expand Down Expand Up @@ -770,7 +770,6 @@ public List<String> generateStatisticsForEachRecipient(String recipientEmail,

Assumption.assertTrue("Weights should be enabled when calling the function", hasAssignedWeights);
List<String> recipientStats = new ArrayList<>();
DecimalFormat df = new DecimalFormat("0.00");

String recipientName = bundle.getNameForEmail(recipientEmail);
String recipientTeam = bundle.getTeamNameForEmail(recipientEmail);
Expand Down Expand Up @@ -799,9 +798,9 @@ public List<String> generateStatisticsForEachRecipient(String recipientEmail,
numOfResponsesForThisRecipient += responseCount;
}

recipientStats.add(df.format(total));
recipientStats.add(TeammatesDecimalFormat.format(total, "0.00"));
average = numOfResponsesForThisRecipient == 0 ? 0 : total / numOfResponsesForThisRecipient;
recipientStats.add(df.format(average));
recipientStats.add(TeammatesDecimalFormat.format(average, "0.00"));

return recipientStats;
}
Expand All @@ -817,16 +816,15 @@ private String getRecipientStatsHeaderFragmentHtml(String header) {
*/
public String getRecipientStatsHeaderHtml() {
StringBuilder headerBuilder = new StringBuilder(100);
DecimalFormat df = new DecimalFormat("#.##");
StringBuilder choicesHtmlBuilder = new StringBuilder(100);

for (int i = 0; i < choices.size(); i++) {
String weight = df.format(weights.get(i));
String weight = TeammatesDecimalFormat.format(weights.get(i), "#.##");
String html = getRecipientStatsHeaderFragmentHtml(choices.get(i) + " [" + weight + "]");
choicesHtmlBuilder.append(html);
}
if (otherEnabled) {
String otherWeightString = df.format(otherWeight);
String otherWeightString = TeammatesDecimalFormat.format(otherWeight, "#.##");
String html = getRecipientStatsHeaderFragmentHtml("Other" + " [" + otherWeightString + "]");
choicesHtmlBuilder.append(html);
}
Expand All @@ -848,7 +846,6 @@ public String getResponseSummaryStatsCsv(Map<String, Integer> answerFrequency, i
String header = "";

StringBuilder fragments = new StringBuilder();
DecimalFormat df = new DecimalFormat("#.##");

// If weights are assigned, CSV file should include 'Weight' and 'Weighted Percentage' column as well.
if (hasAssignedWeights) {
Expand All @@ -859,40 +856,42 @@ public String getResponseSummaryStatsCsv(Map<String, Integer> answerFrequency, i
int responseCount = answerFrequency.get(key);
String weightString = "";
if ("Other".equals(key)) {
weightString = df.format(otherWeight);
weightString = TeammatesDecimalFormat.format(otherWeight, "#.##");
} else {
weightString = df.format(weights.get(choices.indexOf(key)));
weightString = TeammatesDecimalFormat.format(weights.get(choices.indexOf(key)), "#.##");
}

fragments.append(SanitizationHelper.sanitizeForCsv(key)).append(',')
.append(SanitizationHelper.sanitizeForCsv(weightString)).append(',')
.append(Integer.toString(responseCount)).append(',')
.append(df.format(100 * (double) responseCount / totalResponseCount)).append(',')
.append(df.format(weightedPercentagePerOption.get(key))).append(System.lineSeparator());
.append(TeammatesDecimalFormat
.format(100 * (double) responseCount / totalResponseCount, "#.##")).append(',')
.append(TeammatesDecimalFormat
.format(weightedPercentagePerOption.get(key), "#.##")).append(System.lineSeparator());
}
} else {
header = "Choice, Response Count, Percentage (%)";

answerFrequency.forEach((key, value) -> fragments.append(SanitizationHelper.sanitizeForCsv(key)).append(',')
.append(value.toString()).append(',')
.append(df.format(100 * (double) value / totalResponseCount)).append(System.lineSeparator()));
.append(TeammatesDecimalFormat.format(100 * (double) value / totalResponseCount, "#.##"))
.append(System.lineSeparator()));
}

return header + System.lineSeparator() + fragments.toString();
}

public String getPerRecipientResponseStatsHeaderCsv() {
StringBuilder header = new StringBuilder(100);
DecimalFormat df = new DecimalFormat("#.##");

header.append("Team, Recipient Name,");

for (int i = 0; i < numOfChoices; i++) {
String choiceString = choices.get(i) + " [" + df.format(weights.get(i)) + "]";
String choiceString = choices.get(i) + " [" + TeammatesDecimalFormat.format(weights.get(i), "#.##") + "]";
header.append(SanitizationHelper.sanitizeForCsv(choiceString)).append(',');
}
if (otherEnabled) {
String otherOptionString = "Other [" + df.format(otherWeight) + "]";
String otherOptionString = "Other [" + TeammatesDecimalFormat.format(otherWeight, "#.##") + "]";
header.append(SanitizationHelper.sanitizeForCsv(otherOptionString)).append(',');
}
header.append("Total, Average").append(System.lineSeparator());
Expand Down
Loading