<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Separating unit tests and integration tests in Go in Integration and Testing</title>
    <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Separating-unit-tests-and-integration-tests-in-Go/m-p/82982#M52308</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there an established best practice for separating unit tests and integration tests in GoLang (testify)? I have a mix of unit tests (which do not rely on any external resources and thus run really fast) and integration tests (which do rely on any external resources and thus run slower). So, I want to be able to control whether or not to include the integration tests when I say&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;go test.&lt;/P&gt;&lt;P&gt;The most straight-forward technique would seem to be to define a -integrate flag in main:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;var&lt;/SPAN&gt; runIntegrationTests = flag.Bool(&lt;SPAN class=""&gt;"integration"&lt;/SPAN&gt;, &lt;SPAN class=""&gt;false&lt;/SPAN&gt;
    , &lt;SPAN class=""&gt;"Run the integration tests (in addition to the unit tests)"&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;P&gt;And then to add an if-statement to the top of every integration test:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;if&lt;/SPAN&gt; !*runIntegrationTests {
    this.T().Skip(&lt;SPAN class=""&gt;"To run this test, use: go test -integration"&lt;/SPAN&gt;)
}&lt;/PRE&gt;&lt;P&gt;Is this the best I can do? I searched the testify documentation to see if there is perhaps a naming convention or something that accomplishes this for me, but didn't find anything. Am I missing something?&lt;/P&gt;</description>
    <pubDate>Thu, 02 Jun 2022 10:21:37 GMT</pubDate>
    <dc:creator>AnneGoodikona</dc:creator>
    <dc:date>2022-06-02T10:21:37Z</dc:date>
    <item>
      <title>Separating unit tests and integration tests in Go</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Separating-unit-tests-and-integration-tests-in-Go/m-p/82982#M52308</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there an established best practice for separating unit tests and integration tests in GoLang (testify)? I have a mix of unit tests (which do not rely on any external resources and thus run really fast) and integration tests (which do rely on any external resources and thus run slower). So, I want to be able to control whether or not to include the integration tests when I say&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;go test.&lt;/P&gt;&lt;P&gt;The most straight-forward technique would seem to be to define a -integrate flag in main:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;var&lt;/SPAN&gt; runIntegrationTests = flag.Bool(&lt;SPAN class=""&gt;"integration"&lt;/SPAN&gt;, &lt;SPAN class=""&gt;false&lt;/SPAN&gt;
    , &lt;SPAN class=""&gt;"Run the integration tests (in addition to the unit tests)"&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;P&gt;And then to add an if-statement to the top of every integration test:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;if&lt;/SPAN&gt; !*runIntegrationTests {
    this.T().Skip(&lt;SPAN class=""&gt;"To run this test, use: go test -integration"&lt;/SPAN&gt;)
}&lt;/PRE&gt;&lt;P&gt;Is this the best I can do? I searched the testify documentation to see if there is perhaps a naming convention or something that accomplishes this for me, but didn't find anything. Am I missing something?&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jun 2022 10:21:37 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/Separating-unit-tests-and-integration-tests-in-Go/m-p/82982#M52308</guid>
      <dc:creator>AnneGoodikona</dc:creator>
      <dc:date>2022-06-02T10:21:37Z</dc:date>
    </item>
  </channel>
</rss>

