boc-tothefuture / openhab-jruby

JRuby Libraries for Openhab
Eclipse Public License 2.0
6 stars 9 forks source link

bring in rspec-openhab-scripting gem #646

Closed ccutrer closed 1 year ago

ccutrer commented 1 year ago

and convert (most) _type.feature tests to rspec in-process tests.

By running tests in-line, and in-process, massive speed increases are possible, as well as ease of writing tests. You don't have to wrap everything in a rules file, that then gets deployed, wait for OpenHAB to detect it, and then check the results by continually checking the log file. This also allows more particular testing (like the rspec be matcher in the PercentType spec that also checks for type equality).

For this initial proof-of-concept, I converted 28+ cucumber scenarios to specs. The runtime on my computer:

cody@opennuc:~/src/openhab-jruby$ time rspec

Randomized with seed 8442
............................

Finished in 18.4 seconds (files took 2.48 seconds to load)
28 examples, 0 failures

Randomized with seed 8442

real    0m26.233s
user    1m46.645s
sys 0m2.334s

The vast majority of that time is booting up - the actual specs (all of them, not each one) took a fraction of a second to run. This is in stark contrast to cucumber's infrastructure that takes 30-60s to start openhab, and then a minimum of 5 seconds per scenario.

Note this is a re-open of #639

ccutrer commented 1 year ago

Do you envision that we'll be converting more cucumber tests, whenever applicable, into rspec in the future, in separate PRs?

Yes. I've got a whole bunch done already: https://github.com/ccutrer/openhab-jruby/commits/main. The GitHub actions runtime is down from ~10 minutes for the longest Cucumber job to less than 7 minutes. I want to get it down under 3, maybe even 2.

ccutrer commented 1 year ago

@jimtng: done

github-actions[bot] commented 1 year ago

:tada: This PR is included in version 4.46.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

ccutrer commented 1 year ago

🤦 I did it again. This time the gem had time to build. @boc-tothefuture can you yank 4.46.0 from rubygems?