www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - fluent-asserts released

reply Szabo Bogdan <szabobogdan3 gmail.com> writes:
Hi!

I just made an update to my fluent assert library. This is a 
library that allows you to write asserts in a BDD style.

Right now, it contains only asserts that I needed in my projects 
and I promise that I will add more in the future.

I would really appreciate any feedback that you can give me.

https://code.dlang.org/packages/fluent-asserts

Thanks!
Apr 09 2017
next sibling parent reply Jacob Carlborg <doob me.com> writes:
On 2017-04-09 15:30, Szabo Bogdan wrote:
 Hi!

 I just made an update to my fluent assert library. This is a library
 that allows you to write asserts in a BDD style.

 Right now, it contains only asserts that I needed in my projects and I
 promise that I will add more in the future.

 I would really appreciate any feedback that you can give me.

 https://code.dlang.org/packages/fluent-asserts
This looks awesome. Why haven't I seen that before. Can it be used with unit-threaded? -- /Jacob Carlborg
Apr 10 2017
parent reply Szabo Bogdan <szabobogdan3 gmail.com> writes:
On Monday, 10 April 2017 at 12:54:43 UTC, Jacob Carlborg wrote:
 On 2017-04-09 15:30, Szabo Bogdan wrote:
 Hi!

 I just made an update to my fluent assert library. This is a 
 library
 that allows you to write asserts in a BDD style.

 Right now, it contains only asserts that I needed in my 
 projects and I
 promise that I will add more in the future.

 I would really appreciate any feedback that you can give me.

 https://code.dlang.org/packages/fluent-asserts
This looks awesome. Why haven't I seen that before. Can it be used with unit-threaded?
I did not tested it with unit-threaded, but when an assert fails it throws an exception so it should work with any test runner
Apr 10 2017
parent reply Atila Neves <atila.neves gmail.com> writes:
On Monday, 10 April 2017 at 14:15:45 UTC, Szabo Bogdan wrote:
 On Monday, 10 April 2017 at 12:54:43 UTC, Jacob Carlborg wrote:
 On 2017-04-09 15:30, Szabo Bogdan wrote:
 Hi!

 I just made an update to my fluent assert library. This is a 
 library
 that allows you to write asserts in a BDD style.

 Right now, it contains only asserts that I needed in my 
 projects and I
 promise that I will add more in the future.

 I would really appreciate any feedback that you can give me.

 https://code.dlang.org/packages/fluent-asserts
This looks awesome. Why haven't I seen that before. Can it be used with unit-threaded?
I did not tested it with unit-threaded, but when an assert fails it throws an exception so it should work with any test runner
It'll work, but it won't end up reporting it the same way. If you'd like that to work seamlessly it's a question of having `version(Have_unit_threaded)` (or however it is it's spelled) that imports and throws `unit_threaded.should.UnitTestException`. Then Bob's your uncle. Atila
Apr 10 2017
parent Jacob Carlborg <doob me.com> writes:
On 2017-04-10 22:41, Atila Neves wrote:

 It'll work, but it won't end up reporting it the same way. If you'd like
 that to work seamlessly it's a question of having
 `version(Have_unit_threaded)` (or however it is it's spelled) that
 imports and throws `unit_threaded.should.UnitTestException`. Then Bob's
 your uncle.
Ok, I see, thanks. On the other hand I just remembered that unit-threaded already have a very similar API for the assertions. -- /Jacob Carlborg
Apr 11 2017
prev sibling next sibling parent reply jmh530 <john.michael.hall gmail.com> writes:
On Sunday, 9 April 2017 at 13:30:54 UTC, Szabo Bogdan wrote:
 Hi!

 I just made an update to my fluent assert library. This is a 
 library that allows you to write asserts in a BDD style.

 Right now, it contains only asserts that I needed in my 
 projects and I promise that I will add more in the future.

 I would really appreciate any feedback that you can give me.

 https://code.dlang.org/packages/fluent-asserts

 Thanks!
I got really confused looking at the examples until I realized that should returns a struct. You might add an approxEqual for ShouldNumeric. If you have floating point numbers, it's usually more helpful than equal is.
Apr 10 2017
parent Szabo Bogdan <szabobogdan3 gmail.com> writes:
On Monday, 10 April 2017 at 17:38:14 UTC, jmh530 wrote:
 On Sunday, 9 April 2017 at 13:30:54 UTC, Szabo Bogdan wrote:
 Hi!

 I just made an update to my fluent assert library. This is a 
 library that allows you to write asserts in a BDD style.

 Right now, it contains only asserts that I needed in my 
 projects and I promise that I will add more in the future.

 I would really appreciate any feedback that you can give me.

 https://code.dlang.org/packages/fluent-asserts

 Thanks!
I got really confused looking at the examples until I realized that should returns a struct. You might add an approxEqual for ShouldNumeric. If you have floating point numbers, it's usually more helpful than equal is.
thanks! I added 2 issues for your sugestion. I also found some bugs that I will fix in the next release.
Apr 10 2017
prev sibling parent reply qznc <qznc web.de> writes:
On Sunday, 9 April 2017 at 13:30:54 UTC, Szabo Bogdan wrote:
 Hi!

 I just made an update to my fluent assert library. This is a 
 library that allows you to write asserts in a BDD style.

 Right now, it contains only asserts that I needed in my 
 projects and I promise that I will add more in the future.

 I would really appreciate any feedback that you can give me.

 https://code.dlang.org/packages/fluent-asserts

 Thanks!
I was looking for testing exceptions. It is not documented, but the seems to be there. Still, it looks weird, because it does not fit the style: should.not.throwAnyException({ throw new Exception("test"); });
Apr 11 2017
parent reply Szabo Bogdan <szabobogdan3 gmail.com> writes:
On Tuesday, 11 April 2017 at 10:40:53 UTC, qznc wrote:
 On Sunday, 9 April 2017 at 13:30:54 UTC, Szabo Bogdan wrote:
 Hi!

 I just made an update to my fluent assert library. This is a 
 library that allows you to write asserts in a BDD style.

 Right now, it contains only asserts that I needed in my 
 projects and I promise that I will add more in the future.

 I would really appreciate any feedback that you can give me.

 https://code.dlang.org/packages/fluent-asserts

 Thanks!
I was looking for testing exceptions. It is not documented, but the seems to be there. Still, it looks weird, because it does not fit the style: should.not.throwAnyException({ throw new Exception("test"); });
what do you mean, they are not documented? there is a md file fith some examples here: https://github.com/gedaiu/fluent-asserts/blob/v0.3.0/api/exceptions.md What do you think I can do to have the exception asserts to fit the style?
Apr 11 2017
parent reply =?UTF-8?Q?Ali_=c3=87ehreli?= <acehreli yahoo.com> writes:
On 04/11/2017 11:01 PM, Szabo Bogdan wrote:
     should.not.throwAnyException({
       throw new Exception("test");
     });
what do you mean, they are not documented? there is a md file fith some examples here: https://github.com/gedaiu/fluent-asserts/blob/v0.3.0/api/exceptions.md What do you think I can do to have the exception asserts to fit the style?
The expression comes first in the other use cases. The following is not very pretty but seems to work with my proof of concept below: ({ throw new Exception("test"); }()).should.not.throwAnyException(); I checked the syntax with the following code: struct Should { Should not() { return this; } Should throwAnyException() { return this; } } Should should(E)(lazy E expr) { return Should(); } void main() { ({ throw new Exception("test"); }()).should.not.throwAnyException(); } Ali
Apr 11 2017
parent Szabo Bogdan <szabobogdan3 gmail.com> writes:
On Wednesday, 12 April 2017 at 06:22:26 UTC, Ali Çehreli wrote:
 On 04/11/2017 11:01 PM, Szabo Bogdan wrote:
     should.not.throwAnyException({
       throw new Exception("test");
     });
what do you mean, they are not documented? there is a md file fith some examples here: https://github.com/gedaiu/fluent-asserts/blob/v0.3.0/api/exceptions.md What do you think I can do to have the exception asserts to fit the style?
The expression comes first in the other use cases. The following is not very pretty but seems to work with my proof of concept below: ({ throw new Exception("test"); }()).should.not.throwAnyException(); I checked the syntax with the following code: struct Should { Should not() { return this; } Should throwAnyException() { return this; } } Should should(E)(lazy E expr) { return Should(); } void main() { ({ throw new Exception("test"); }()).should.not.throwAnyException(); } Ali
Hi! I managed to make another update to the library. http://fluentasserts.szabobogdan.com/ Based on your feedback I updated the exception asserts and I added some new ones like `Between` and `Approximately`. Also now it works with unit-threaded. Thanks for the feedback!
Apr 18 2017