Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7419915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:09:07+00:00 2026-05-29T08:09:07+00:00

I like to keep my unit tests pretty simple and easy to follow. I

  • 0

I like to keep my unit tests pretty simple and easy to follow. I often hardcode the expected results of a test in order to avoid repeating the code that I am testing. In addition, I often use data-driven tests. For example, if I am testing the format that a date/time is presented as, I will sometimes hard-code the expected string, ie. “1/1/2000” or “1:00 PM”. However, since date and time formats are culture-specific and our app is localizable, the actual output COULD vary. However, my team is based in the U.S. and so this is usually not a problem. Our continuous integration and build servers run with U.S. culture info as well.

There is a team member who has complained because he has changed the date format on his dev machine to manually test other date formats, and so many tests fail for him. Should I be using the current culture information when testing outputs in unit tests, or is this hard-coding acceptable?

UPDATE: I ended up setting a specific locale for certain tests.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T08:09:07+00:00Added an answer on May 29, 2026 at 8:09 am

    Unit tests should be 100% repeatable, regardless of the environment in which they run. The only reason for a unit test to start failing is because the code changed and broke the test.

    So yes, you need to take steps to ensure that your tests continue to pass regardless of external factors.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing unit tests for a module in a small Javascript application. In order
I'm trying to decide on a naming convention for unit tests. I like the
I would like to know how to write unit tests for a module that
Requirements I would like to keep an audit log of particular events, such as:
I would like to keep first link as default selected with javascript, here is
I would like to keep model binding when doing ajax calls from my view.
I'd like to keep my components/assemblies clearly separated from a source code point of
I'd like to keep my database clean of stale almost-accounts, and I was thinking
I'd like to keep some information on the client which element was clicked and
I'd like to keep my concrete classes separate from my views. Without using strongly

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.