-
-
Notifications
You must be signed in to change notification settings - Fork 683
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
Add cron expression assertion support in assertj-core #3212
Comments
@neilwangweili thanks for the idea, I agree having cron assertions would be a good addition. AssertJ has a no-dependency policy thus we would need to define
|
@joel-costigliola WOW! Thank you for the affirmation. Can I write a pr to try it out? |
Hi, there? @joel-costigliola |
Go for it, @neilwangweili! |
You mean we write our own set of cron expression parsers? <dependency>cron.parser</dependency>
<artifactId>xxx</artifactId>
<version>xxx</version> public class CronExpression {
private final cron.parser.CronExpression expression;
// constructor
public void isValid() {
expression.isValid();
}
} |
No new dependency should be added so we have to introduce our own implementation. |
That's cool |
We take inspiration from an open source implementation of cron expression but we would need to be careful with the licenses |
Some simple valuable api's have been done. #3220 |
Feature Summary
Origin Of The Problem
Assertion of cron expressions in a project is also very important, and a programmer writing a wrong cron expression in a project can even cause a disaster. According to the idea of TDD, before writing a correct cron expression, you should use tests to express the expectation that the cron expression wants to achieve. But I haven't found a particularly convenient way to do this, and this is my current solution, which makes use of
org.springframework.scheduling.support.CronExpression
:My Interim Solution
My Thoughts
I think this could also be wrapped by the
assertj
framework, it looks like it should be under theassertj-core
package. In this way, timed tasks in software code can be used with greater confidence and testing to verify their functionality is simple.Example
Perhaps the test code for a programmer using the
assertj-core
framework to solve cron expression validation is as follows:This is a prototype of what I envision the api to be, and it may need more refined thought.
A Few Doubts
I think it's a great feature to support, and it fills in the points of vulnerability in the testing framework. I am interested in this and would like to contribute to this project on this issue. Please let me know if this feature goes against the original intent of the project.
The text was updated successfully, but these errors were encountered: