Skip to content
DataMiner DoJo

More results...

Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Search in posts
Search in pages
Search in posts
Search in pages
Log in
Menu
  • Updates & Insights
  • Questions
  • Learning
    • E-learning Courses
    • Empower Replay: Limited Edition
    • Tutorials
    • Open Classroom Training
    • Certification
      • DataMiner Fundamentals
      • DataMiner Configurator
      • DataMiner Automation
      • Scripts & Connectors Developer: HTTP Basics
      • Scripts & Connectors Developer: SNMP Basics
      • Visual Overview – Level 1
      • Verify a certificate
    • Video Library
    • Books We Like
    • >> Go to DataMiner Docs
  • Expert Center
    • Solutions & Use Cases
      • Solutions
      • Use Case Library
    • Markets & Industries
      • Media production
      • Government & defense
      • Content distribution
      • Service providers
      • Partners
      • OSS/BSS
    • Agile
      • Agile Webspace
      • Everything Agile
        • The Agile Manifesto
        • Best Practices
        • Retro Recipes
      • Methodologies
        • The Scrum Framework
        • Kanban
        • Extreme Programming
      • Roles
        • The Product Owner
        • The Agile Coach
        • The Quality & UX Coach (QX)
    • DataMiner DevOps Professional Program
      • About the DevOps Program
      • DataMiner DevOps Support
  • Downloads
  • More
    • DataMiner Releases & Updates
    • Feature Suggestions
    • Climb the leaderboard!
    • Swag Shop
    • Contact
    • Global Feedback Survey
  • PARTNERS
    • All Partners
    • Technology Partners
    • Strategic Partner Program
    • Deal Registration
  • >> Go to dataminer.services

Unit test passing but not passing on pipeline

Solved1.02K views20th February 2023pipeline Unit Test
6
Luis Gonzalez [SLC] [DevOps Advocate]475 17th February 2023 0 Comments

Hello Dojo Community

I'm working on a unit test for a simple method that evaluates a string expression and returns the value of that expression. i.e.: Input: "1 + 2" returns 3 as double.

I did the unit test and when I run/debug them I see the correct values and the test passes, however when I push the driver through the pipeline the test seems to fail.
I've tried multiple ways to assert the result:
- Parsing to string with the same number of decimals
- Rounding both values with the same number of decimals
- Getting the difference of both values and asserting that is below a certain value
- Asserting that the doubles are equal with a value of tolerance set

This is one example of code I've done:

string goodOperation = "0.0840435203018592- 1.5";
double goodOperationResult = -1.41596;
goodOperationResult = Math.Round(goodOperationResult, 5);

var goodOperationTestResult = TrendingDataHelper.Evaluate(goodOperation);
goodOperationTestResult = Math.Round(goodOperationTestResult, 5);

Assert.AreEqual(goodOperationResult, goodOperationTestResult, 0.00001);

All of those are working in the code and the test passes correctly and when I debug I see the correct values, but all fail on the pipeline.

Is there something I'm doing wrong or is a better way to assert doubles?

Thanks in advance!

Luis Gonzalez [SLC] [DevOps Advocate] Selected answer as best 20th February 2023

1 Answer

  • Active
  • Voted
  • Newest
  • Oldest
2
Michiel Vanthuyne [SLC] [DevOps Enabler]4.16K Posted 20th February 2023 2 Comments

Hi Luis, could the failure be related to regional formatting? Some areas of the world use the dot '.' as decimal separator, while others use the comma ','. If the pipeline server has a different regional setting from the machine you used to test locally that could be the cause. The best way is to make your code robust for this by specifying the expected format when parsing strings.

Luis Gonzalez [SLC] [DevOps Advocate] Posted new comment 20th February 2023
Pedro Debevere [SLC] [DevOps Enabler] commented 20th February 2023

Indeed, this is the issue, in your implementation you use a DataTable to perform the expression evaluation. There you set the local to CultureInfo.InvariantCulture. However, when parsing the result you do the following:
var result = double.Parse((string)row[“expression”]);
By changing this to:
var result = double.Parse((string)row[“expression”], CultureInfo.InvariantCulture);
the test should now also succeed on the Jenkins server.

Luis Gonzalez [SLC] [DevOps Advocate] commented 20th February 2023

Hi Michiel and Pedro
I updated the code to add the InvariantCulture on the method Pedro indicated and it worked.
Thanks for the help! I’ll keep in mind the formatting when dealing with these cases.

You are viewing 1 out of 1 answers, click here to view all answers.
Please login to be able to comment or post an answer.

My DevOps rank

DevOps Members get more insights on their profile page.

My user earnings

0 Dojo credits

Spend your credits in our swag shop.

0 Reputation points

Boost your reputation, climb the leaderboard.

Promo banner DataMiner DevOps Professiona Program
DataMiner Integration Studio (DIS)
Empower Katas
Privacy Policy • Terms & Conditions • Contact

© 2025 Skyline Communications. All rights reserved.

DOJO Q&A widget

Can't find what you need?

? Explore the Q&A DataMiner Docs

[ Placeholder content for popup link ] WordPress Download Manager - Best Download Management Plugin