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 #8977

Closed
wants to merge 79 commits into from

Conversation

tshradheya
Copy link
Member

Fixes #8844

Ongoing.

@LiHaoTan Need your input on the Intellij use default reporter

Would appreciate if someone can try out the following for me and check if it works on Eclipse

1. Change the language of eclipse IDE to German.
2. Run `TimeHelperTest` and ensure it fails
3. Make the necessary changes in `gradle.properties` as made in this PR
4. After rebuilding run the same test again and ensure it passes.

Outline of Solution

  • Made default reported being true so that its standardized for IntelliJ
  • Ensured tests are not locale-dependent
  • Corrected minor problem in documentation

NOTE: Continued from #8845 as I messed up the old PR :P

@tshradheya tshradheya added the s.ToReview The PR is waiting for review(s) label Jul 20, 2018
@tshradheya tshradheya requested a review from LiHaoTan July 20, 2018 09:39
@tshradheya tshradheya closed this Jul 20, 2018
@tshradheya tshradheya reopened this Jul 20, 2018
@tshradheya tshradheya closed this Jul 20, 2018
@LiHaoTan LiHaoTan reopened this Jul 22, 2018
Copy link
Contributor

@LiHaoTan LiHaoTan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know which PR to review since you closed all of them so I suppose I will review this.

Let's add something like IllegalImport in CheckStyle to disallow DecimalFormat and DateTimeFormatter with custom messages.

See if it's possible to disallow fully qualified classes too (I don't think so).

/**
* Returns DateTimeFormatter instance with Locale.US as default locale.
*/
public static DateTimeFormatter ofPattern(String pattern) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return a TeammatesDateTimeFormatter instead.

Also, add a format method that we can use instead.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return a TeammatesDateTimeFormatter instead.

How exactly?

My idea is that since we set the locale while setting the pattern, I will only wrap that function so that after that function returns the DateTimeFormatter we can use other DateTimeFormatter functions with the required set locale.
This will save us from the hassle of wrapping every function and will make sure code works once TeammatesDateTimeFormatter.ofPattern has been used

Similarly for this https://github.com/TEAMMATES/teammates/pull/8977/files#r204227822

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LiHaoTan Need your input on this

Copy link
Contributor

@LiHaoTan LiHaoTan Jul 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My idea is that it should wrap every function (like a forwarding class) precisely to prevent unexpected behaviors.

For example one could do TeammatesDateTimeFormatter.ofPattern(...).withLocale(...); and that is not something we want.

Anyway in any case we don't have to wrap every function if we don't treat TeammatesDateTimeFormatter as an extension of DateTimeFormatter but rather the class is just a formatter and the fact that it uses DateTimeFormatter is merely an implementation detail.

import java.util.Locale;

/**
* DateTimeFormatter for TEAMMATES with default Locale.US settings.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like this may be better?
DateTimeFormatter with TEAMMATES specific defaults (i.e. US locale).

@@ -211,6 +213,7 @@ private String getInstructorQuestionResultsStatisticsHtml(
df.setMinimumFractionDigits(0);
df.setMaximumFractionDigits(5);
df.setRoundingMode(RoundingMode.DOWN);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like StringHelper.toDecimalFormatString is not flexible enough. Let's create a TeammatesDecimalFormat for that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s.ToReview The PR is waiting for review(s)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants