<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Simon Bäumer</title>
    <description>The latest articles on DEV Community by Simon Bäumer (@simonbaeumer).</description>
    <link>https://dev.to/simonbaeumer</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F569%2F9550466.jpeg</url>
      <title>DEV Community: Simon Bäumer</title>
      <link>https://dev.to/simonbaeumer</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/simonbaeumer"/>
    <language>en</language>
    <item>
      <title>My first open source project - super simple cli testing tool</title>
      <dc:creator>Simon Bäumer</dc:creator>
      <pubDate>Mon, 01 Apr 2019 08:51:00 +0000</pubDate>
      <link>https://dev.to/simonbaeumer/my-first-open-source-project-super-simple-cli-testing-tool-gcd</link>
      <guid>https://dev.to/simonbaeumer/my-first-open-source-project-super-simple-cli-testing-tool-gcd</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;In this article I will cover my first open source project &lt;code&gt;commander&lt;/code&gt;. It tests cli apps based on tests defined in a simple &lt;code&gt;yaml&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;Check it out: &lt;a href="https://github.com/SimonBaeumer/commander"&gt;https://github.com/SimonBaeumer/commander&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem?
&lt;/h2&gt;

&lt;p&gt;For another project I needed a tool which had the following abilities:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use the same tool for different operating systems (mainly osx, linux, windows)&lt;/li&gt;
&lt;li&gt;Simple and easy writing of tests&lt;/li&gt;
&lt;li&gt;Simple installation (no heavy lib or language installation)&lt;/li&gt;
&lt;li&gt;Language independent&lt;/li&gt;
&lt;li&gt;pls not another DSL&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Especially the heavy installation and language independence were important for me because I wanted to test an app inside different docker containers.&lt;/p&gt;

&lt;p&gt;Sadly there wasn't a single tool for it. &lt;code&gt;bats&lt;/code&gt; just works for bash, go's &lt;code&gt;icmd&lt;/code&gt; and python's &lt;code&gt;expect&lt;/code&gt; require you to install a language and be familiar with it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why using &lt;code&gt;commander&lt;/code&gt;?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Easy installation&lt;/li&gt;
&lt;li&gt;Generate tests automatically&lt;/li&gt;
&lt;li&gt;Fast execution&lt;/li&gt;
&lt;li&gt;Platform independent&lt;/li&gt;
&lt;li&gt;Just &lt;code&gt;yaml&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;Download the binary and give it execution permissions. If you want to call it directly from your terminal add it your &lt;code&gt;path&lt;/code&gt; environment variable.&lt;/p&gt;

&lt;h3&gt;
  
  
  Linux &amp;amp; osx
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# linux amd64&lt;/span&gt;
curl &lt;span class="nt"&gt;-L&lt;/span&gt; https://github.com/SimonBaeumer/commander/releases/download/v1.0.1/commander-linux-amd64 &lt;span class="nt"&gt;-o&lt;/span&gt; commander
&lt;span class="nb"&gt;chmod&lt;/span&gt; +x commander 

&lt;span class="c"&gt;# osx amd64&lt;/span&gt;
curl &lt;span class="nt"&gt;-L&lt;/span&gt; https://github.com/SimonBaeumer/commander/releases/download/v1.0.1/commander-darwin-amd64 &lt;span class="nt"&gt;-o&lt;/span&gt; commander
&lt;span class="nb"&gt;chmod&lt;/span&gt; +x commander 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  windows amd64
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nf"&gt;curl&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-L&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;https://github.com/SimonBaeumer/commander/releases/download/v1.0.1/commander-windows-amd64.exe&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-o&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;commander.exe&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;... or download it manually and add it to your &lt;code&gt;path&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quick start!
&lt;/h2&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Let commander create your test!&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;.commander add &lt;span class="nb"&gt;echo &lt;/span&gt;hello dev.to
written to /current/working/dir/commander.yaml

&lt;span class="c"&gt;# ... written to the default commander.yaml&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cat &lt;/span&gt;commander.yaml
tests:
  &lt;span class="nb"&gt;echo &lt;/span&gt;hello dev.to:
    exit-code: 0
    stdout: hello dev.to

&lt;span class="c"&gt;# Executes the generated commander config&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;commander &lt;span class="nb"&gt;test
&lt;/span&gt;Starting &lt;span class="nb"&gt;test &lt;/span&gt;file commander.yaml...

✓ &lt;span class="nb"&gt;echo &lt;/span&gt;hello dev.to

Duration: 0.003s
Count: 1, Failed: 0
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  A full &lt;code&gt;commander.yaml&lt;/code&gt; example
&lt;/h2&gt;

&lt;p&gt;As you can see the test suite is easy to understand and write.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;tests&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;echo hello world&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;stdout&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;lines&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;1&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;hello world&lt;/span&gt; &lt;span class="c1"&gt;# assert a specifc line&lt;/span&gt;
      &lt;span class="na"&gt;contains&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;hello world&lt;/span&gt; &lt;span class="c1"&gt;# this is the default&lt;/span&gt;
      &lt;span class="na"&gt;exactly&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;hello&lt;/span&gt; &lt;span class="c1"&gt;# Match stdout exactly&lt;/span&gt;
    &lt;span class="c1"&gt;# The same can be done for stderr&lt;/span&gt;
    &lt;span class="na"&gt;exit-code&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;
    &lt;span class="na"&gt;config&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;timeout&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;5ms&lt;/span&gt; &lt;span class="c1"&gt;# set timeout for test&lt;/span&gt;
      &lt;span class="na"&gt;dir&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/tmp&lt;/span&gt; &lt;span class="c1"&gt;# set working dir&lt;/span&gt;
      &lt;span class="na"&gt;env&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;SOME_ENV&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;value&lt;/span&gt;

  &lt;span class="na"&gt;it should have a title&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="c1"&gt;# You can also define a title to be more clear...&lt;/span&gt;
    &lt;span class="na"&gt;command&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;echo title&lt;/span&gt; &lt;span class="c1"&gt;# ... and define your command under test here&lt;/span&gt;
    &lt;span class="na"&gt;exit-code&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Define default test configs
&lt;/h2&gt;

&lt;p&gt;Further you can define a default configuration for all tests. This can be overwritten by the local test configs.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;config&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="c1"&gt;# Define the config globally&lt;/span&gt;
  &lt;span class="na"&gt;timeout&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;5ms&lt;/span&gt;
  &lt;span class="na"&gt;dir&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/tmp&lt;/span&gt;
  &lt;span class="na"&gt;env&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;KEY&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;VALUE&lt;/span&gt;

&lt;span class="na"&gt;tests&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;print env and dir&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;command&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;echo&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;$KEY&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;$(pwd)"&lt;/span&gt;
    &lt;span class="na"&gt;stdout&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;VALUE /tmp&lt;/span&gt;
    &lt;span class="na"&gt;exit-code&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Debbuging tests
&lt;/h2&gt;

&lt;p&gt;Sometimes you need to debug your commands. This can be done with &lt;code&gt;--verbose&lt;/code&gt; flag.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Generate the test&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;commander add &lt;span class="nb"&gt;echo &lt;/span&gt;hello dev.to

&lt;span class="c"&gt;# Execute it with logging output&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;commander &lt;span class="nb"&gt;test&lt;/span&gt; &lt;span class="nt"&gt;--verbose&lt;/span&gt;
Starting &lt;span class="nb"&gt;test &lt;/span&gt;file commander.yaml...

2019/03/28 16:56:48 title: &lt;span class="s1"&gt;'echo hello dev.to'&lt;/span&gt;  ExitCode:  0
2019/03/28 16:56:48 title: &lt;span class="s1"&gt;'echo hello dev.to'&lt;/span&gt;  Stdout:  hello dev.to
2019/03/28 16:56:48 title: &lt;span class="s1"&gt;'echo hello dev.to'&lt;/span&gt;  Stderr:  
✓ &lt;span class="nb"&gt;echo &lt;/span&gt;hello dev.to

Duration: 0.002s
Count: 1, Failed: 0
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Executing
&lt;/h2&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Execute another file instead of the default&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;commander &lt;span class="nb"&gt;test &lt;/span&gt;another.yaml

&lt;span class="c"&gt;# Filter tests&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;commander &lt;span class="nb"&gt;test &lt;/span&gt;commander.yaml &lt;span class="s2"&gt;"echo hello"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Generating tests
&lt;/h2&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Add a test to the default commander.yaml&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;./commander add &lt;span class="nb"&gt;echo &lt;/span&gt;hello
written to /tmp/commander.yaml

&lt;span class="c"&gt;# Write to a given file&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;./commander add &lt;span class="nt"&gt;--file&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;test.yaml &lt;span class="nb"&gt;echo &lt;/span&gt;hello
written to test.yaml

&lt;span class="c"&gt;# Write to stdout and file&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;./commander add &lt;span class="nt"&gt;--stdout&lt;/span&gt; &lt;span class="nb"&gt;echo &lt;/span&gt;hello
tests:
  &lt;span class="nb"&gt;echo &lt;/span&gt;hello:
    exit-code: 0
    stdout: hello

written to /tmp/commander.yaml

&lt;span class="c"&gt;# Only to stdout&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;./commander add &lt;span class="nt"&gt;--stdout&lt;/span&gt; &lt;span class="nt"&gt;--no-file&lt;/span&gt; &lt;span class="nb"&gt;echo &lt;/span&gt;hello
tests:
  &lt;span class="nb"&gt;echo &lt;/span&gt;hello:
    exit-code: 0
    stdout: hello
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;With &lt;code&gt;commander&lt;/code&gt; you can easy generate your test cases and execute them on different platforms without learning a new language or installing annoying libs and tools.&lt;/p&gt;

&lt;p&gt;Contributions are always warmly welcomed!&lt;/p&gt;

&lt;p&gt;I hope some of you can use it in their projects :)&lt;/p&gt;

&lt;p&gt;Link: &lt;a href="https://github.com/SimonBaeumer/commander"&gt;https://github.com/SimonBaeumer/commander&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Notice: Please give me feedback for my first blog post!&lt;/p&gt;

</description>
      <category>testing</category>
      <category>go</category>
      <category>opensource</category>
      <category>shell</category>
    </item>
    <item>
      <title>Hi, I'm Simon BÃ¤umer</title>
      <dc:creator>Simon Bäumer</dc:creator>
      <pubDate>Mon, 07 Nov 2016 12:24:00 +0000</pubDate>
      <link>https://dev.to/simonbaeumer/hi-im-simon-bumer</link>
      <guid>https://dev.to/simonbaeumer/hi-im-simon-bumer</guid>
      <description>&lt;p&gt;I have been coding for 7 years (atm I am 23years young), started coding in School and continued it as a trainee for 3 years. Now I am full employed since Jule 2016 as a Web Developer.&lt;/p&gt;

&lt;p&gt;I live in Germany, Steinfurt, and work for the eCommerce company shopware.&lt;br&gt;
The most time I develop PHP applications but I am generally interested in any programming language, i.e. Ruby or Java. &lt;br&gt;
Further I love concepts like LoD, TDD, SOLID, DDD and I love to learn more about it.&lt;/p&gt;

&lt;p&gt;Nice to meet you!&lt;/p&gt;

&lt;p&gt;You can find me on GitHub as &lt;a href="https://github.com/SimonBaeumer" rel="noopener noreferrer"&gt;@SimonBaeumer&lt;/a&gt;&lt;/p&gt;

</description>
      <category>introduction</category>
    </item>
  </channel>
</rss>
