<?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 Re: 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/82847#M52209</link>
    <description>&lt;P&gt;&lt;SPAN&gt;short is a good option, as is your custom build flags, but your flags need not be in main. if you define the var as&amp;nbsp;&lt;/SPAN&gt;var integration = flag.Bool("integration", true, "Enable integration testing.")&lt;SPAN&gt;&amp;nbsp;outside of a function, the variable will show up in package scope, and the flag will&amp;nbsp;omglz.com work&amp;nbsp;omegle.2yu.co properly&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 24 May 2022 11:15:49 GMT</pubDate>
    <dc:creator>BillyAkinbredal</dc:creator>
    <dc:date>2022-05-24T11:15:49Z</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/82746#M52141</link>
      <description>&lt;P&gt;Hi&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>Wed, 18 May 2022 11:50:48 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/Separating-unit-tests-and-integration-tests-in-Go/m-p/82746#M52141</guid>
      <dc:creator>RickyReyesmatri</dc:creator>
      <dc:date>2022-05-18T11:50:48Z</dc:date>
    </item>
    <item>
      <title>Re: 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/82763#M52151</link>
      <description>&lt;P&gt;As a similar option, you could also have integration tests run by default by using a build condition&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;// +build !unit, and then disable them on demand by running&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;go test -tags=unit.&lt;/P&gt;&lt;P&gt;@adamc comments:&lt;/P&gt;&lt;P&gt;For anyone else attempting to use build tags, it's important that the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;// +build test&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;comment is the first line in your file, and that you include a blank line after the comment, otherwise the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;-tags&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;command will ignore the directive.&lt;/P&gt;&lt;P&gt;Also, the tag used in the build comment cannot have a dash, although underscores are allowed. For example,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;// +build unit-tests&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;will not work, whereas&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;// +build unit_tests&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;will.&lt;/P&gt;</description>
      <pubDate>Thu, 19 May 2022 07:35:07 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/Separating-unit-tests-and-integration-tests-in-Go/m-p/82763#M52151</guid>
      <dc:creator>VictorJohnsonan</dc:creator>
      <dc:date>2022-05-19T07:35:07Z</dc:date>
    </item>
    <item>
      <title>Re: 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/82847#M52209</link>
      <description>&lt;P&gt;&lt;SPAN&gt;short is a good option, as is your custom build flags, but your flags need not be in main. if you define the var as&amp;nbsp;&lt;/SPAN&gt;var integration = flag.Bool("integration", true, "Enable integration testing.")&lt;SPAN&gt;&amp;nbsp;outside of a function, the variable will show up in package scope, and the flag will&amp;nbsp;omglz.com work&amp;nbsp;omegle.2yu.co properly&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2022 11:15:49 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/Separating-unit-tests-and-integration-tests-in-Go/m-p/82847#M52209</guid>
      <dc:creator>BillyAkinbredal</dc:creator>
      <dc:date>2022-05-24T11:15:49Z</dc:date>
    </item>
  </channel>
</rss>

