Jump to page: 1 24  
Page
Thread overview
Unencumbered V0.1.2: Write Cucumber step definitions in D
Apr 23, 2014
Atila Neves
Apr 23, 2014
Jacob Carlborg
Apr 23, 2014
Atila Neves
Apr 24, 2014
Jacob Carlborg
Apr 24, 2014
Atila Neves
Apr 24, 2014
Jacob Carlborg
Apr 25, 2014
Atila Neves
Apr 26, 2014
Jacob Carlborg
Apr 28, 2014
Atila Neves
Apr 25, 2014
Dejan Lekic
Apr 25, 2014
Sönke Ludwig
Apr 25, 2014
Atila Neves
Apr 25, 2014
Atila Neves
Apr 24, 2014
Jacob Carlborg
Apr 25, 2014
Atila Neves
Apr 25, 2014
Atila Neves
Apr 25, 2014
Rikki Cattermole
Apr 25, 2014
Dicebot
Apr 25, 2014
Rikki Cattermole
Apr 25, 2014
Atila Neves
Apr 25, 2014
Dicebot
Apr 25, 2014
John Colvin
Apr 25, 2014
Atila Neves
Apr 26, 2014
Jacob Carlborg
Apr 28, 2014
Atila Neves
Apr 26, 2014
Jacob Carlborg
May 02, 2014
Atila Neves
May 04, 2014
Jacob Carlborg
Apr 24, 2014
Jacob Carlborg
Apr 25, 2014
Atila Neves
Apr 26, 2014
Jacob Carlborg
Apr 28, 2014
Atila Neves
April 23, 2014
Like testing with Cucumber? Wish you could call native D code with it? Now you can!

http://code.dlang.org/packages/unencumbered
https://github.com/atilaneves/unencumbered

I especially like registering functions that take the parameters with the types they need from the regexp captures, as well as the compile-time failures that come from that if done incorrectly.

Now I just need to use in "real life".

Atila
April 23, 2014
On 23/04/14 15:24, Atila Neves wrote:
> Like testing with Cucumber? Wish you could call native D code with it?
> Now you can!
>
> http://code.dlang.org/packages/unencumbered
> https://github.com/atilaneves/unencumbered
>
> I especially like registering functions that take the parameters with
> the types they need from the regexp captures, as well as the
> compile-time failures that come from that if done incorrectly.
>
> Now I just need to use in "real life".

This is awesome. I've been thinking several times about implementing something like this. Now I don't have to :)

How do I set up the environment to use this? How complicated is it with the server and wire protocol?

-- 
/Jacob Carlborg
April 23, 2014
Thanks. :)

The examples directory (which actually only contains one example) shows what is the bare minimum needed. You need:

1. A file with the .wire extension with the host and port for cucumber to connect to in features/step_definitions (just like the example). Cucumber automatically finds this
2. An "app" D source file that tells the compiler which modules to look for step definitions in at compile-time. These are passed in as compile-time string parameters to cucumber.server.runCucumberServer (look at examples/source/app.d)
3. Compile the server app with its dependencies by using dub or the build system of choice
4. Run the server, run cucumber in another shell, marvel at the results :P

The only thing that may be confusing in the example directory is the fact that the modules that app.d references are themselves in the `tests` directory. The reason being that I actually use them for unit tests too and as we all know, duplication is bad.

I expect to run the acceptance / feature tests from a shell script that compiles and runs the server, runs cucumber then brings the server down. Now that I think of it it should be possible to do that from Cucumber itself by using `After` and `Before`. I had to do something like that whilst bootstrapping the process and also for some tests I wrote for my MQTT broker. I think this should work but I can't try it right now so don't trust me:

    Before do
      @server = IO.popen("./your_server_name")
      Timeout.timeout(1) do
        while @socket.nil?
          begin
            @socket = TCPSocket.new('localhost', port)
          rescue Errno::ECONNREFUSED
            #keep trying until the server is up or we time out
          end
        end
      end
    end

    After do
      @socket.nil? or @socket.close
      if not @server.nil?
        Process.kill("INT", @server.pid)
        Process.wait(@server.pid)
      end
    end

The reason it should work is that Cucumber supports mixing step definitions in Ruby and over the wire. Which is awesome.

Atila

On Wednesday, 23 April 2014 at 14:58:26 UTC, Jacob Carlborg wrote:
> On 23/04/14 15:24, Atila Neves wrote:
>> Like testing with Cucumber? Wish you could call native D code with it?
>> Now you can!
>>
>> http://code.dlang.org/packages/unencumbered
>> https://github.com/atilaneves/unencumbered
>>
>> I especially like registering functions that take the parameters with
>> the types they need from the regexp captures, as well as the
>> compile-time failures that come from that if done incorrectly.
>>
>> Now I just need to use in "real life".
>
> This is awesome. I've been thinking several times about implementing something like this. Now I don't have to :)
>
> How do I set up the environment to use this? How complicated is it with the server and wire protocol?

April 24, 2014
On 23/04/14 19:17, Atila Neves wrote:
> Thanks. :)
>
> The examples directory (which actually only contains one example) shows
> what is the bare minimum needed. You need:
>
> 1. A file with the .wire extension with the host and port for cucumber
> to connect to in features/step_definitions (just like the example).
> Cucumber automatically finds this
> 2. An "app" D source file that tells the compiler which modules to look
> for step definitions in at compile-time. These are passed in as
> compile-time string parameters to cucumber.server.runCucumberServer
> (look at examples/source/app.d)
> 3. Compile the server app with its dependencies by using dub or the
> build system of choice
> 4. Run the server, run cucumber in another shell, marvel at the results :P
>
> The only thing that may be confusing in the example directory is the
> fact that the modules that app.d references are themselves in the
> `tests` directory. The reason being that I actually use them for unit
> tests too and as we all know, duplication is bad.

Aha, their they are. I didn't noticed the step definitions before. Especially confusing since you do have a step_definitions directory.

> I expect to run the acceptance / feature tests from a shell script that
> compiles and runs the server, runs cucumber then brings the server down.
> Now that I think of it it should be possible to do that from Cucumber
> itself by using `After` and `Before`. I had to do something like that
> whilst bootstrapping the process and also for some tests I wrote for my
> MQTT broker. I think this should work but I can't try it right now so
> don't trust me:
>
>      Before do
>        @server = IO.popen("./your_server_name")
>        Timeout.timeout(1) do
>          while @socket.nil?
>            begin
>              @socket = TCPSocket.new('localhost', port)
>            rescue Errno::ECONNREFUSED
>              #keep trying until the server is up or we time out
>            end
>          end
>        end
>      end
>
>      After do
>        @socket.nil? or @socket.close
>        if not @server.nil?
>          Process.kill("INT", @server.pid)
>          Process.wait(@server.pid)
>        end
>      end
>
> The reason it should work is that Cucumber supports mixing step
> definitions in Ruby and over the wire. Which is awesome.

Cool. Have you considered embedding Ruby in some executable and call the D functions from Ruby. To avoid the server and wire protocol.

-- 
/Jacob Carlborg
April 24, 2014
> Aha, their they are. I didn't noticed the step definitions before. Especially confusing since you do have a step_definitions directory.

I think I had to create that directory to put the .wire file in there. I can't remember.

> Cool. Have you considered embedding Ruby in some executable and call the D functions from Ruby. To avoid the server and wire protocol.

I did, yeah, that's why I asked that question recently about calling D from Ruby. I also thought of using Thrift and played about with it but in the end decided that the simplest option is to just use the wire protocol. It even reports back D exception information back, so the only real thing I can see that's missing is the snippet suggestions when the steps aren't defined yet.

Atila
April 24, 2014
On 24/04/14 09:19, Atila Neves wrote:

> I did, yeah, that's why I asked that question recently about calling D
> from Ruby.

Right, that was you.

> I also thought of using Thrift and played about with it but
> in the end decided that the simplest option is to just use the wire
> protocol. It even reports back D exception information back, so the only
> real thing I can see that's missing is the snippet suggestions when the
> steps aren't defined yet.

If Ruby is embedded Cucumber could be embedded as well, perhaps. Then you could get an executable without dependencies.

-- 
/Jacob Carlborg
April 24, 2014
On 2014-04-23 15:24, Atila Neves wrote:
> Like testing with Cucumber? Wish you could call native D code with it?
> Now you can!
>
> http://code.dlang.org/packages/unencumbered
> https://github.com/atilaneves/unencumbered
>
> I especially like registering functions that take the parameters with
> the types they need from the regexp captures, as well as the
> compile-time failures that come from that if done incorrectly.
>
> Now I just need to use in "real life".

BTW, why is the description passed as a template argument to the Cucumber keywords. @Given!("foo") instead of @Given("foo")?

-- 
/Jacob Carlborg
April 24, 2014
On 2014-04-23 15:24, Atila Neves wrote:
> Like testing with Cucumber? Wish you could call native D code with it?
> Now you can!
>
> http://code.dlang.org/packages/unencumbered
> https://github.com/atilaneves/unencumbered
>
> I especially like registering functions that take the parameters with
> the types they need from the regexp captures, as well as the
> compile-time failures that come from that if done incorrectly.
>
> Now I just need to use in "real life".

It would be very nice to have something like Aruba in D together with this. If you haven't heard of it it's basically a library making it easier to test CLI applications, often used together with Cucumber. I think it's used by Cucumber itself.

-- 
/Jacob Carlborg
April 25, 2014
On Thursday, 24 April 2014 at 14:10:07 UTC, Jacob Carlborg wrote:
> On 24/04/14 09:19, Atila Neves wrote:
>
>> I did, yeah, that's why I asked that question recently about calling D
>> from Ruby.
>
> Right, that was you.
>
>> I also thought of using Thrift and played about with it but
>> in the end decided that the simplest option is to just use the wire
>> protocol. It even reports back D exception information back, so the only
>> real thing I can see that's missing is the snippet suggestions when the
>> steps aren't defined yet.
>
> If Ruby is embedded Cucumber could be embedded as well, perhaps. Then you could get an executable without dependencies.

Or I could carry on implementing all the Cucumber features and end up with an executable that does everything the Ruby version does. I'm happy with what I've got now though, but the embedding thing is interesting. I just decided that embedding was too much work.

Atila
April 25, 2014
On Thursday, 24 April 2014 at 18:55:20 UTC, Jacob Carlborg wrote:
> On 2014-04-23 15:24, Atila Neves wrote:
>> Like testing with Cucumber? Wish you could call native D code with it?
>> Now you can!
>>
>> http://code.dlang.org/packages/unencumbered
>> https://github.com/atilaneves/unencumbered
>>
>> I especially like registering functions that take the parameters with
>> the types they need from the regexp captures, as well as the
>> compile-time failures that come from that if done incorrectly.
>>
>> Now I just need to use in "real life".
>
> It would be very nice to have something like Aruba in D together with this. If you haven't heard of it it's basically a library making it easier to test CLI applications, often used together with Cucumber. I think it's used by Cucumber itself.

Yeah, I know Aruba. Well, for all of about two weeks :) Why would you want Aruba in D, though? You can just use the Ruby version.

Atila
« First   ‹ Prev
1 2 3 4