Time formats doesn`t work in GEB 3.4

30 views
Skip to first unread message

Gordon Freeman

unread,
Apr 3, 2020, 9:59:28 AM4/3/20
to Geb User Mailing List
Hi, everyone! 
I would like to discuss one strange behavior with Calendar in 3.4 version of GEB.
Previously we used old version 2.1 and such construction worked perfectly:
Calendar.getInstance().format('MMddHHmmss')

But I decided to try the newest version 3.4:
Calendar.getInstance().format('MMddHHmmss')// - doesn`t work format()

I was able to 'fix' it just changed to:
Calendar.getInstance().toOffsetDateTime().format("MMddHHmmss")

But we used such constructions in more than 100 places, fine I can do refactor, but also noticed that 'TimeCategory' is not working in new GEB version, next construction was working in GEB 2.1 but in 3.4 doesn`t work:
newDate=null
use(TimeCategory) {
    newDate
= 8.weeks.ago.format('MMddHHmmss').toString()
    println
(newDate)
}

How can I fix this? Is it possible do not refactor everything with new version of GEB?
Thanks in advance!

Just in case, our dependencies:
reportiumVersion = '2.3.1'
gebVersion
= '2.1' //3.4 also tried
groovyVersion
= '2.4.12'
junitVersion
= '5.6.1'
seleniumVersion
= '3.141.59'
dependencies {
compile "org.gebish:geb-spock:$gebVersion"
compile "org.codehaus.groovy:groovy-all:$groovyVersion"
compile "com.perfecto.reporting-sdk:reportium-java:$reportiumVersion"
compile "com.perfecto.reporting-sdk:reportium-testng:$reportiumVersion"
compile group'org.ccil.cowan.tagsoup'name'tagsoup'version'1.2.1'
testCompile("org.spockframework:spock-core:1.2-groovy-2.4") {
exclude group"org.codehaus.groovy"
}
testCompile('com.athaydes:spock-reports:1.3.1') {
transitive = false 
}
testImplementation("org.junit.jupiter:junit-jupiter:$junitVersion")
compile "org.seleniumhq.selenium:selenium-chrome-driver:$seleniumVersion"
compile "org.seleniumhq.selenium:selenium-firefox-driver:$seleniumVersion"
compile "org.seleniumhq.selenium:selenium-ie-driver:$seleniumVersion"
compile "org.seleniumhq.selenium:selenium-remote-driver:$seleniumVersion"
compile "org.seleniumhq.selenium:selenium-support:$seleniumVersion"
}

Alexander Kriegisch

unread,
Apr 5, 2020, 5:52:02 AM4/5/20
to geb-...@googlegroups.com
I am not a Geb guy, I use Maven. But I created a little sample project,
trying to use the same dependency versions as you, and did not notice
any anomalies with calendar instances or time units. If you do have
problems, please be so kind as to make them reproducible by publishing
an MCVE [1] on GitHub. I like to have a full Gradle or Maven project and
a Spock or Geb test reproducing your problem. By the way, you did not
even explain what the problem is, except saying "doesn't work". I see no
detailed error description, no stacktrace or anything else that could be
helpful.

[1] https://stackoverflow.com/help/mcve

Looking forward to your update :-)

--
Alexander Kriegisch
https://scrum-master.de
> --
> You received this message because you are subscribed to the Google Groups
> "Geb User Mailing List" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to geb-user+u...@googlegroups.com
> <mailto:geb-user+u...@googlegroups.com> .
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/geb-user/386a81cd-1c87-4653-b903-89cf81bf9192%40googlegroups.com
> <https://groups.google.com/d/msgid/geb-user/386a81cd-1c87-4653-b903-89cf81bf9192%40googlegroups.com?utm_medium=email&utm_source=footer>
> .

Alexander Kriegisch

unread,
Apr 5, 2020, 6:26:46 AM4/5/20
to geb-...@googlegroups.com
Okay, my own Maven POM was "too correct" in order to reproduce your
error. You ought to change a few things:

-- Geb 3.3 depends on Groovy 2.5.6, so you want to use at least
** org.codehaus.groovy:groovy:2.5.6
** org.spockframework:spock-core:1.2-groovy-2.5

-- Class DateGroovyMethods (adding dynamic methods to Date) is
deprecated in Groovy 2.5, you want to use class DateUtilExtensions
instead. But for that you ought to add dependency
** org.codehaus.groovy:groovy-dateutil:2.5.6

Then a test like this works:

package de.scrum_master.geb

import geb.spock.GebSpec
import groovy.time.TimeCategory

class CalendarTest extends GebSpec {
def test() {
given:
println Calendar.getInstance().format('MMddHHmmss')
use(TimeCategory) {
println 8.weeks.ago.format('MMddHHmmss').toString()
}

expect:
true
}
}

It prints something like:

0405172557
0209000000


--
Alexander Kriegisch
https://scrum-master.de


> to geb-user+u...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/geb-user/20200405095159.C7A5544C03D8%40dd39516.kasserver.com.
>

Gordon Freeman

unread,
Apr 5, 2020, 6:57:04 AM4/5/20
to Geb User Mailing List
Thanks a lot! Just added
org.codehaus.groovy:groovy-dateutil:2.5.6

And it helped. 👍
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/geb-user/386a81cd-1c87-4653-b903-89cf81bf9192%40googlegroups.com
>> <https://groups.google.com/d/msgid/geb-user/386a81cd-1c87-4653-b903-89cf81bf9192%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>
> --
> You received this message because you are subscribed to the Google Groups "Geb
> User Mailing List" group.
> To unsubscribe from this group and stop receiving emails from it, send an email

Alexander Kriegisch

unread,
Apr 5, 2020, 7:37:49 AM4/5/20
to geb-...@googlegroups.com
You are welcome. BTW, I hope you don't mean you added a Groovy 2.5
library to your Groovy 2.4 project and left the rest unchanged. That
would not sound so good, but hopefully I just misunderstood and you did
re-align your dependency management.
--
Alexander Kriegisch
https://scrum-master.de


>> <https://stackoverflow.com/help/mcve> help/mcve
>> >> email to geb-...@ <java-script:> googlegroups.com
>> >> <mailto:geb-...@ <java-script:> googlegroups.com> .
>> >> To view this discussion on the web visit
>> >> https://groups.google.com/d/
>> <https://groups.google.com/d/msgid/geb-user/386a81cd-1c87-4653-b903-89cf81bf9192%40googlegroups.com>
>> msgid/geb-user/386a81cd-1c87-4653-b903-89cf81bf9192%40googlegroups.com
>> >> <https://groups.google.com/d/
>> <https://groups.google.com/d/msgid/geb-user/386a81cd-1c87-4653-b903-89cf81bf9192%40googlegroups.com?utm_medium=email&utm_source=footer>
>> msgid/geb-user/386a81cd-1c87-4653-b903-89cf81bf9192%40googlegroups.com?utm_medium=email&utm_source=footer>
>> >> .
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups "Geb
>> > User Mailing List" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> an email
>> > to geb-...@ <java-script:> googlegroups.com.
>> > To view this discussion on the web visit
>> > https://groups.google.com/d/
>> <https://groups.google.com/d/msgid/geb-user/20200405095159.C7A5544C03D8%40dd39516.kasserver.com>
>> msgid/geb-user/20200405095159.C7A5544C03D8%40dd39516.kasserver.com.
>> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "Geb User Mailing List" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to geb-user+u...@googlegroups.com
> <mailto:geb-user+u...@googlegroups.com> .
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/geb-user/c7808f3d-66e2-4b5a-8e8a-6e00bcecff7f%40googlegroups.com
> <https://groups.google.com/d/msgid/geb-user/c7808f3d-66e2-4b5a-8e8a-6e00bcecff7f%40googlegroups.com?utm_medium=email&utm_source=footer>
> .

Gordon Freeman

unread,
Apr 5, 2020, 9:19:56 AM4/5/20
to Geb User Mailing List
I additionally only changed groovy version to 2.5.10 because we use old version of Spock and for update to the newest groovy version we have to made many changes in spock report classes.
Reply all
Reply to author
Forward
0 new messages