Lädt...


🔧 Tests with time


Nachrichtenbereich: 🔧 Programmierung
🔗 Quelle: dev.to

I encountered the issue when my tests passed locally, but some of them failed on CI. Initially, I thought it was a problem with incorrect configuration of the running task or pipeline environment. I tried several solutions, but none worked. Surprisingly, it was only after that I decided to check which tests had failed. The issue was clear: it was related to time.
Failed tests
These tests cover the logic of parsing a string into LocalDateTime.  Parsing involves local time, which requires information about the time zone. I get this information from a static method that returns the time zone of the running environment: TimeZone.currentSystemDefault(). In tests, I use a string with a specific time and assert against a time related to my time zone. As a result, the tests passed on my local machine but failed on the CI machine, which operates in a different time zone. 

The solution was obvious: I need to provide a specific time zone for the tests to make them independent of the environment. To achieve this, I needed to extract the logic of obtaining time zone information as a dependency, allowing it to be configured for tests.

fun Any.parsToLocalDateTime(timeZone: TimeZone = TimeZone.currentSystemDefault()): LocalDateTime? {

You can find more useful content on my LinkedIn page, on X, in Medium or Mastodon.

...

🔧 Unit tests and integration tests. Things I feared most when I studied.


📈 17.13 Punkte
🔧 Programmierung

🔧 Testing in Rust: A Quick Guide to Unit Tests, Integration Tests, and Benchmarks


📈 17.13 Punkte
🔧 Programmierung

🔧 JUnit Tests in Java: A Guide to Writing Effective Unit Tests


📈 17.13 Punkte
🔧 Programmierung

🕵️ Etherpad Frontend Tests up to 1.6.0 tests.js directory traversal


📈 17.13 Punkte
🕵️ Sicherheitslücken

🕵️ Etherpad Frontend Tests bis 1.6.0 tests.js Directory Traversal


📈 17.13 Punkte
🕵️ Sicherheitslücken

🔧 How to write unit tests and E2E tests for NestJS applications


📈 17.13 Punkte
🔧 Programmierung

📰 Ask Slashdot: Is it Time To Call Time on Time Zones?


📈 15.32 Punkte
📰 IT Security Nachrichten

📰 Slashdot Asks: Is It Time To Dump Time Zones In Favor of Coordinated Universal Time?


📈 15.32 Punkte
📰 IT Security

📰 Slashdot Asks: Is It Time To Dump Time Zones In Favor of Coordinated Universal Time?


📈 15.32 Punkte
📰 IT Security

🔧 Tests with time


📈 13.67 Punkte
🔧 Programmierung

🔧 Measuring Your Website Performance: A Step-by-Step Guide to Page Load Time Tests


📈 13.67 Punkte
🔧 Programmierung

🔧 How to save time when run RSpec tests


📈 13.67 Punkte
🔧 Programmierung

🔧 Simplify Your Tests and Save Time: A Guide to Test Data Builders


📈 13.67 Punkte
🔧 Programmierung

📰 Better Together: Real Time Threat Detection for Kubernetes with Atomic Red Tests & Falco


📈 13.67 Punkte
📰 IT Security Nachrichten

🎥 Execute tests with HyperExecute's Just In Time Orchestration | ODFP230


📈 13.67 Punkte
🎥 Video | Youtube

🔧 Mastering Time Complexity in Ruby: A Comprehensive Guide with Code Examples and Tests


📈 13.67 Punkte
🔧 Programmierung

📰 Online Tests Suggest IQ Scores In US Dropped For the First Time In Nearly a Century


📈 13.67 Punkte
📰 IT Security Nachrichten

📰 Why Are Some Wealthy Kids Getting Extra Time To Finish Their SAT Tests?


📈 13.67 Punkte
📰 IT Security Nachrichten

📰 Security reloaded: Single-Point-in-Time-Tests versagen bei DevOps


📈 13.67 Punkte
📰 IT Security Nachrichten

🐧 Time Formatting in Go (Time to String)


📈 10.21 Punkte
🐧 Linux Tipps

🔧 Time to Leave? Time to Rebuild! Making Twitter2.0


📈 10.21 Punkte
🔧 Programmierung

🍏 Time Machine Schedule 1.0.0 - Schedule Time Machine backups and view the progress in your Menu Bar.


📈 10.21 Punkte
🍏 iOS / Mac OS

🐧 Would you recommend Linux over Windows for casual user whom just browses from time to time?


📈 10.21 Punkte
🐧 Linux Tipps

📰 Real-Time Payments, Real-Time Fraud Risks?


📈 10.21 Punkte
📰 IT Security

🪟 Another day, another accusation on OpenAI for stealing content; this time from TIME Magazine


📈 10.21 Punkte
🪟 Windows Tipps

🔧 Edge Cases to Keep in Mind. Part 3 — Time of Check to Time of Use Race Conditions in Android UI


📈 10.21 Punkte
🔧 Programmierung

🍏 Battery Time 1.0.0 - Always view the remaining battery time in your Menu Bar.


📈 10.21 Punkte
🍏 iOS / Mac OS

🐧 [Grub] Windows 10 time keeps resetting to Greenwich time


📈 10.21 Punkte
🐧 Linux Tipps

matomo