<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Hui Ching Lim on Medium]]></title>
        <description><![CDATA[Stories by Hui Ching Lim on Medium]]></description>
        <link>https://medium.com/@huichinglim?source=rss-ba0af76158fe------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*S74Og3GaLV8b7e1auDAm0Q.jpeg</url>
            <title>Stories by Hui Ching Lim on Medium</title>
            <link>https://medium.com/@huichinglim?source=rss-ba0af76158fe------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 03:45:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@huichinglim/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Test Development Patterns and Anti-Patterns]]></title>
            <link>https://medium.com/test-go-where/test-development-patterns-and-anti-patterns-78820e1802df?source=rss-ba0af76158fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/78820e1802df</guid>
            <category><![CDATA[quality-assurance]]></category>
            <category><![CDATA[software-testing]]></category>
            <category><![CDATA[automation-testing]]></category>
            <category><![CDATA[test-development]]></category>
            <category><![CDATA[design-patterns]]></category>
            <dc:creator><![CDATA[Hui Ching Lim]]></dc:creator>
            <pubDate>Sun, 08 Aug 2021 09:03:50 GMT</pubDate>
            <atom:updated>2021-08-14T09:10:07.617Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*woq_MyXnJlPKTpLB1tJ2RQ.jpeg" /></figure><p>Have you ever wonder what would be the difference between the code written by a Developer vs Quality Assurance(QA) Engineer?</p><p>Test development, similar to software development we need to have design patterns in order for us solve the recurring problems such as unreadable code, inconsistency coding patterns, high efforts of maintaining the test code, etc.</p><p>Let’s share across the best coding practices, DOs and DONTs during Test Development in this article.</p><h3>Code Review Practices</h3><p>Code Review process is critical in test development as it helps to maintain the consistent patterns, minimise the errors, ensuring QA written the “right” test code.</p><h4>DOs</h4><ol><li><strong>Use Merge Request Template</strong></li></ol><p>By having a MR template, it could be used as a checklist when QA submitting their MR for a code review. It’s a good way to enforce ourselves to do self-code review and check everything. Refer article below for more details:</p><p><a href="https://medium.com/automated-testing/merge-request-template-example-in-automated-testing-9bcb4675526a">Merge Request Template Example in Automated Testing</a></p><p><strong>2. Review your code first</strong></p><p>Without this, reviews will have too many comments that could be avoided at the first place such as: spelling errors, formatting and reviewer might missed out the more important things. Try to avoid such:</p><ul><li>Anti-patterns</li><li>Formatting/spelling mistakes</li><li>Ambiguous code and comments; missing and incorrect comment; missing asserts</li><li>Too many changes that make review process complicated (like simultaneous refactoring)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uOzlCAYdOW2Qo-ghh2nuRw.jpeg" /></figure><p><strong>3. Test your code</strong></p><p>Code is expected to be working with all relevant tests passing. Review process is not designed to verify that the code works. So, it’s time for QA to assure our own test code!</p><p><strong>4. Clearly indicate the goal of the review</strong></p><p>Quite often there is a need to do preliminary review, when only particular ideas are being offered for review, such as a big test code refactoring, AT for a big feature, etc. In that case it is very important to let reviewers know that the code is only a draft and only particular types of comments are expected. WIP/Draft in a MR subject helps.</p><p><strong>5. Focus on the code itself</strong></p><p>It’s totally understandable that sometimes we might felt code review could be a bit bitter(or actually sweet), as your code is challenged by someone else and it’s not a good feeling. But let us just focus on the code itself.</p><p>When we are being challenged, please keep in mind that:</p><p>Say, if Tom is coding something by following the patterns of some existing code from Jerry, and Peter, the code reviewer challenges Tom: “Hey Tom, your code has a problem”, then Tom:</p><ul><li>Should not: complaint that: “Hey, it’s the same or similar code copied from Jerry, why don’t you challenge Jerry but me?”</li><li>Should (after understanding the issues): “Oh ya it’s correct, it’s not a good solution, let me inform Jerry or help him to his part too.”</li></ul><h3>Coding practices — DOs</h3><h4><strong>Use composition in place of spreading the same properties everywhere</strong></h4><p><strong>Anti-pattern</strong></p><pre>//InitPartConsumer ...<br>func InitPartitionConsumer(consumer sarama.Consumer, topic string, partition int, offset int64) (partconsumer sarama.PartitionConsumer, err error) {<br>// do something<br>}</pre><pre>func GetKafkaMsgFromMultiPartitions(addr, topic string, maxPartNum int, offset int64, timeout int) (result []string) {<br>// do something<br>}</pre><p>What’s wrong: the <strong><em>topic</em></strong> and <strong><em>addr</em></strong> are everywhere</p><p><strong>How to fix: Use composition</strong></p><pre>type KafkaConn struct {<br>    Topic   string<br>    Addr    string<br>    Timeout int<br>    Offset  int64<br>}<br> <br>func (k *KafkaConn) InitPartitionConsumer(consumer sarama.Consumer) (partConsumer sarama.PartitionConsumer, err error) {<br>// do something<br>}<br> <br> <br>func (k *KafkaConn) GetKafkaMsgFromMultiPartitions(maxPartNum int) (result []string) {<br>// do something<br>}</pre><p>Don’t you feel it’s much cleaner and comfortable?</p><h4>Use ‘require’ function to reiterate an array</h4><p><strong>Anti-pattern</strong></p><pre>actual := search.Send()<br>assert.Equal(t, int32(http.StatusOK), actual.Status)<br>for _, s := range actual.Groups {<br>   for _, k := range s.GetData() {<br>      if k.GetBubbleTeaId() == ExpBubbleTeaId {<br>         assert.Equal(t, ExpBubbleId, k.GetBubbleId())<br>         assert.Equal(t, ExpSugarLevel, k.GetSugarLevel())<br>         assert.Equal(t, ExpDeliveryId, k.GetDeliveryId())<br>      }<br>   }<br>}</pre><p>What’s wrong: If actual.Groups is [], the assert will not be exercised</p><p><strong>How To Fix: Use require library</strong></p><p>github.com/stretchr/testify/require</p><pre>require.NotEmpty(t, k.GetBubbleTeaId())<br> for _, s := range actual.Groups {<br>  for _, k := range s.GetData() {<br>   assert.Equal(t, ExpBubbleId, k.GetBubbleId())<br>   assert.Equal(t, ExpSugarLevel, k.GetSugarLevel())<br>   assert.Equal(t, ExpDeliveryId, k.GetDeliveryId())<br>  }<br> }</pre><h4>Compute results ahead of time</h4><p><strong>Anti-pattern</strong></p><pre><strong>for</strong> _, actual := range actualResp.GetBbt() {<br>  var validBbtID = regexp.MustCompile(`^[a-z]+\[[0-9]+\]$`)<br>  // do something<br>}</pre><p>What’s wrong: Pattern compile operation is invoked multiple times, produces the same result. Every invocation takes execution time</p><p><strong>How to fix</strong></p><pre>var validBbtID = regexp.MustCompile(`^[a-z]+\[[0-9]+\]$`)<br><strong>for</strong> _, actual := range actualResp.GetBbt() {<br>  // do something<br>}</pre><h4>Make test code chatty enough</h4><p><strong>Why? </strong>A test should be somewhat chatty, to give a warm fuzzy feeling that it’s actually doing what it supposed to do. If we are going to report the failure reason or root cause, how can we know what does the test is actually doing?</p><p>If you are considering to make a test less chatty, let’s put it as an option when the test is running in a normal way. It will be very frustrating when a test crashes unexpectedly and there is no helpful context written to the output before the crash occured.</p><p><strong>How can chatty test solve the problem? </strong>In general, the tests written by your team are hard to review because they are complex tests, and because they don’t log any details as the tests are executing. Sometimes, to help understand the test code, we can try to run it or even try to insert bugs into the test code to see how does the test can detects them.</p><p><strong>When it’s not chatty enough? </strong>It does not help teammates or code reviewer to understand how the test executes if it’s totally inscrutable and does not write anything to a log file or write out any files.</p><p>Chatty tests are also useful to verify that the test is working as intended. Sometimes, tests can have bugs too! Be chatty enough so that it is obvious for the test to show it is doing what it is supposed to, and to give context in case of an unexpected failure, but don’t be so verbose that you make it difficult to find the useful info when you need it.</p><h4>Handle async* responses with a lock</h4><p>Supposed it needs to send 100 concurrent requests to server and assert 1 OKand 99 NOT_OK</p><p><strong>Anti-pattern</strong></p><pre>var (<br> OK     = 0<br> NOT_OK = 0<br>)</pre><pre>func doSync(bbtId uint64, resultMap *RequestMap, wg *sync.WaitGroup) {<br> defer wg.Done()<br> var (<br>  bbtDeliveryId = bbtId<br> )<br> req := &amp;bbtProto.SyncDeliveryRequest{<br>  shopId:        nil,<br>  bbtDeliveryId: proto.Uint64(bbtDeliveryId),<br> }<br> resp := &amp;bbtProto.SyncDeliveryResponse{}<br> code := common.sendRequest(req, resp, endpoint.SyncDeliveryCMD)<br> if int32(code) == ErrorOK {<br>  OK++<br>  return<br> }<br> if (int32(code) == utils.ErrorTimeout) || (int32(code) == int32(ERROR_LOCK_FAILED)) {<br>  NOT_OK++<br>  return<br> }<br>}</pre><pre>func Test_delivery_sync_duplicate_task(t *testing.T) {<br> var (<br>  bbtDeliveryId                = uint64(55138390163352)<br>  ConcurrentDuplicatedSyncTask = 20<br> )<br> client.Connect()<br> results := RequestMap{<br>  data: map[string]int{PassFlag: 0, FailFlag: 0},<br> }<br> var wg sync.WaitGroup<br> for i := 0; i &lt; ConcurrentDuplicatedSyncTask; i += 1 {<br>  wg.Add(1)<br>  go doSync(bbtDeliveryId, &amp;results, &amp;wg)<br> }<br> wg.Wait()<br> assert.Equal(t, 1, OK)<br> assert.Equal(t, 99, NOT_OK)<br>}</pre><p><strong>What’s wrong:</strong></p><ul><li>The requests are concurrent, so the responses are also concurrent. Above code will have race issue when handling the OK++ / NOT_OK++. If it has two PASS and two PASS try to do OK++ in the same time, OK will be still +1</li><li>Use a lock to handle responses when requests are concurrent</li></ul><p><strong>How to fix</strong></p><pre>type RequestMap struct {<br> data map[string]int<br> sync.RWMutex<br>}</pre><pre>const (<br> PassFlag = &quot;PASS&quot;<br> FailFlag = &quot;FAIL&quot;<br>)</pre><pre>func doSync(bbtId uint64, resultMap *RequestMap, wg *sync.WaitGroup) {<br> defer wg.Done()<br> var (<br>  bbtDeliveryId = bbtId<br> )<br> req := &amp;bbtProto.SyncDeliveryRequest{<br>  shopId:        nil,<br>  bbtDeliveryId: proto.Uint64(bbtDeliveryId),<br> }<br> resp := &amp;bbtProto.SyncDeliveryResponse{}<br> code := common.sendRequest(req, resp, endpoint.SyncDeliveryCMD)<br> if int32(code) == ErrorOK {<br>  resultMap.Lock()<br>  defer resultMap.Unlock()<br>  resultMap.data[PassFlag] += 1<br>  return<br> }<br> if (int32(code) == utils.ErrorTimeout) || (int32(code) == int32(ERROR_LOCK_FAILED)) {<br>  resultMap.Lock()<br>  defer resultMap.Unlock()<br>  resultMap.data[FailFlag] += 1<br>  return<br> }<br>}</pre><pre>func Test_delivery_sync_duplicate_task(t *testing.T) {<br> var (<br>  bbtDeliveryId                = uint64(55138390163352)<br>  ConcurrentDuplicatedSyncTask = 20<br> )<br> client.Connect()<br> results := RequestMap{<br>  data: map[string]int{PassFlag: 0, FailFlag: 0},<br> }<br> var wg sync.WaitGroup<br> for i := 0; i &lt; ConcurrentDuplicatedSyncTask; i += 1 {<br>  wg.Add(1)<br>  go doSync(bbtDeliveryId, &amp;results, &amp;wg)<br> }<br> wg.Wait()<br> assert.Equal(t, 1, OK)<br> assert.Equal(t, 99, NOT_OK)<br>}</pre><h4>Use Builder design pattern for a big request</h4><p>If a request object is big, use Builder design pattern to build it with default values</p><p><strong>Anti-pattern</strong></p><pre>// just use a json here to show how complicated the req is<br>    reqJson := ` {<br>                &quot;query_id&quot;: &quot;demo&quot;,<br>                &quot;request_info&quot;: {<br>                  &quot;timestamp&quot;: 1593070231,<br>                  &quot;request_id&quot;: &quot;central.sg2.6jRWx4rXoGQmFmrS75f5Y001&quot;<br>                },<br>                &quot;bubble_tea_info&quot;: {<br>                  &quot;with_bubble&quot;: true,<br>                  &quot;sugar_level&quot;: 0<br>                },<br>                &quot;item_group_info&quot;: {<br>                  &quot;tea_id&quot;: 9988000,<br>                  &quot;total_price&quot;: 100000,<br>                  &quot;is_regular&quot;: true,<br>                  &quot;group_id&quot;: 1,<br>                  &quot;item_infos&quot;: [<br>                    {<br>                      &quot;bbt_id&quot;: 1915067,<br>                      &quot;cup_size&quot;: 0,<br>                      &quot;with_toppings&quot;: false,<br>                      &quot;quantity&quot;: 1<br>                    }<br>                  ]<br>                },<br>        &quot;toppings_info&quot;: {<br>                &quot;type&quot;: &quot;golden_bubble&quot;,<br>                  &quot;amount&quot;: 2<br>                },<br>                &quot;shop_info&quot;: {<br>                  &quot;seller_id&quot;: null,<br>                  &quot;shop_id&quot;: 367561<br>                },<br>                &quot;delivery_info&quot;: {<br>                  &quot;self_pickup&quot;: false,<br>                  &quot;delivery_code&quot;: &quot;&quot;,<br>                  &quot;delivery_addr&quot;: &quot;&quot;,<br>                }<br>              }`<br> <br>req := &amp;bubbleTeaProto.GroupBuyBubbleTeaRequest{}<br>json.Unmarshal([]byte(reqJson), req)</pre><p><strong>What’s wrong:</strong></p><ul><li>It is very difficult to maintain an object in json. If use regular assignment to prepare an object, it is very tedious and prone to error</li><li>The builder pattern is a design pattern designed to provide a flexible solution to various object creation problems in object-oriented programming. The intent of the Builder design pattern is to separate the construction of a complex object from its representation</li></ul><pre>newBbtInfo := bbt_info.New().WithSugarLevel(defaultSugarLevel).<br> WithCupSize(defaultCupSize).<br> WithToppings(defaultToppings)</pre><pre>newBbtGroupInfo := bbt_group_info.New().WithDeliveryInfos(append(make([]*bbtProto.DeliveryInfo, 0), newBbtInfo.BuildByDeliveryMethods(deliveryId)))</pre><pre>newShopInfo := shop_info.New().WithShopId(defaultShopId).WithSellerId(defaultSellerId)</pre><pre>req := builder.NewMenu().WithBbtGroupInfo(newBbtGroupInfo.BuildByDeliveryMethods(deliveryId)).<br>WithShopInfo(newShopInfo.BuildByDeliveryMethods(deliveryId)).BuildByDeliveryMethods(deliveryId)</pre><h4>Write a checker to assert a big response</h4><p><strong>Anti-pattern</strong></p><pre>func Test_bubble_tea_service_delivery_peak_hour(t *testing.T) {<br>    //...<br>    assert.Equal(t, 1234, actual.BbtId)<br>    assert.Equal(t, 5678, actualAccount.DeliveryId)<br>    assert.Equal(t, 2, actualAccount.SugarLevel)<br>}<br> <br> <br>func Test_bubble_tea_service_delivery_non_peak_hour(t *testing.T) {<br>    //...<br>    assert.Equal(t, 1234, actual.BbtId)<br>    assert.Equal(t, 5678, actualAccount.DeliveryId)<br>    assert.Equal(t, 2, actualAccount.SugarLevel)<br>}</pre><p><strong>What’s wrong:</strong> The same assert is spread everywhere and the maintainability is low</p><p><strong>How to fix:</strong></p><pre>// in a common class<br>func (bbt *BBT) Assert(a *bbtProto.Services) (string, bool) {<br>   if bbt.DeliveryId != a.GetDeliveryId() {<br>      return fmt.Sprintf(&quot;bbt.DeliveryId. Expected: %d. Actual:%d&quot;, bbt.DeliveryId, a.GetDeliveryId()), false<br>   }<br>   if bbt.ShopId != a.GetShopid() {<br>      return fmt.Sprintf(&quot;bbt.ShopId. Expected: %d. Actual:%d&quot;, bbt.ShopId, a.GetShopid()), false<br>   }<br>}<br> <br> <br>func Test_bubble_tea_service_delivery_peak_hour(t *testing.T) {<br>    //...<br>    bbtChecker := &amp;bbtProto.Services{<br>        BbtId: 1234,<br>        DeliveryId: 5678,<br>        SugarLevel: 2,<br>    }<br>    r, b := bbtChecker.Assert(actualBbt)<br>    assert.True(t, b, r)<br>}<br> <br> <br>func Test_bubble_tea_service_delivery_non_peak_hour(t *testing.T) {<br>    //...<br>    bbtChecker := &amp;bbtProto.Services{<br>        BbtId: 1234,<br>        DeliveryId: 5678,<br>        SugarLevel: 2,<br>    }<br>    r, b := bbtChecker.Assert(actualBbt)<br>    assert.True(t, b, r)<br>}</pre><h4>Use plain method to CRUD data</h4><p><strong>Anti-pattern</strong></p><p>In some test code, we need to verify if cache or data in DB is inserted after a request is sent. We should avoid using the same approach with product code (dev) to get the cache and then do the assert. It will:</p><p><strong>What’s wrong:</strong></p><p>It is a testing methodology problem, “Avoid using dev’s product code to test their product code. Write your own utils code (do not over design, make it straightforward as writing test case) to test” — this one has two advantages:</p><ul><li>If using a buggy code to test a buggy code, it may be difficult to find a bug from itself.</li><li>It will make our test repo very huge. Actually, if we just copy/paste codes from product repos, QA test repo will be full of product codes from all of the product repos and it will be extremely huge and complicated.</li></ul><p>Making the test repo too complicated to let junior QA lacking programming experience to join the effort.</p><ul><li>The product’s code is full of concurrency, transaction, logging, and performance codes which are totally redundant to QA’s usage. We just need to write a simple client to read/write data. (Remember our goal, to Keep It Simple and Stupid)</li></ul><p><strong>How to fix</strong></p><ul><li>For caches, DB operation, Kafka, etc., we just write some “hello-world” CRUD using raw technologies (cache ADD/DEL, etc., DB SQL CRUD…)</li></ul><h4>Re-format your code to conform to language coding standard</h4><p>Code conventions are important to programmers for a number of reasons:</p><ul><li>80% of the lifetime cost of a piece of software (so is a testware) goes to maintenance.</li><li>Hardly any software (so is a testware) is maintained for its whole life by the original author.</li><li>Code conventions improve the readability of the software, allowing new joiners to understand new code more quickly and thoroughly.</li></ul><p>Re-format source code, we can use IDE to re-style code to conform i.e. golang code standard.</p><p><em>Goland: </em><em>option + cmd + L. Code will be automatically reformatted for you.</em></p><h3>DONTs</h3><p>After so many DOs, let’s see what are the DONTs that we can avoid in Test Development.</p><h4>Copy-paste</h4><p>Not only for test development, copy-paste bugs are also very common in product code. Just do a copy-paste without enough modification carelessly</p><p><strong>Anti-pattern</strong></p><pre>case bbtProto.CollectionType_SELF_PICKUP:<br>   q = fmt.Sprintf(<br>      &quot;upad:t=%d_uid=%s_bid=%s_type=self_pickup:%s&quot;,<br>      alignedT,<br>      fmt.Sprint(CFG.Buyer.UserId),<br>      fmt.Sprint(CFG.BbtMap[bbtDataKey].BbtId),<br>      fmt.Sprint(CFG.BbtMap[bbtDataKey].ItemId))<br>case bbtProto.CollectionType_DELIVERY:<br>   q = fmt.Sprintf(<br>      &quot;upad:t=%d_uid=%s_bid=%s_type=self_pickup:%s&quot;,<br>      alignedT,<br>      fmt.Sprint(CFG.Buyer.UserId),<br>      fmt.Sprint(CFG.BbtMap[bbtDataKey].BbtId),<br>      fmt.Sprint(CFG.BbtMap[bbtDataKey].ItemId))</pre><p><strong>What’s wrong:</strong> Should there be a need to change the logic, the change should happen in a few places</p><pre>case bbtProto.CollectionType_SELF_PICKUP:<br>   q = fmt.Sprintf(<br>      &quot;upad:t=%d_uid=%s_bid=%s_type=self_pickup:%s&quot;,<br>      alignedT,<br>      fmt.Sprint(CFG.Buyer.UserId),<br>      fmt.Sprint(CFG.BbtMap[bbtDataKey].BbtId),<br>      fmt.Sprint(CFG.BbtMap[bbtDataKey].ItemId))<br>case bbtProto.CollectionType_DELIVERY:<br>   q = fmt.Sprintf(<br>      &quot;upad:t=%d_uid=%s_aid=%s_type=delivery:%s&quot;,<br>      alignedT,<br>      fmt.Sprint(CFG.Buyer.UserId),<br>      fmt.Sprint(CFG.BbtMap[bbtDataKey].BbtId),<br>      fmt.Sprint(CFG.BbtMap[bbtDataKey].ItemId))</pre><h4>Leaving temporary files behind</h4><p><strong>Anti-pattern</strong></p><pre>func (k *Consumer) Consume(file string) {<br>   f, _ := os.Create(file)<br>   w := bufio.NewWriter(f)<br>   defer func() {<br>      if err := recover(); err != nil {<br>         f.Close()<br>         return<br>      }<br>   }()</pre><p><strong>What’s wrong: </strong>File is not removed</p><p><strong>How to fix</strong></p><pre>func (k *Consumer) Consume(file string) {<br>   f, _ := os.Create(file)<br>   w := bufio.NewWriter(f)<br>   defer func() {<br>      if err := recover(); err != nil {<br>         f.Close()<br>         os.Remove(file)<br>         return<br>      }<br>   }()</pre><h4>Meaningless variable names</h4><p><strong>Anti-pattern</strong></p><pre>b := bbtPkg.NewBBT(bbtProto.CollectionType_SELF_PICKUP, &quot;PEAK&quot;)<br>c := collectPkg.New().<br>   WithStatus(bbtProto.NonDelivered)<br>a.UpdateStatus(c)<br> <br>mn := deduct.New().<br>   WithAccountBalance(totalAmount)<br>a.UpdateMoneyData(mn)</pre><p><strong>What’s wrong:</strong> Unable to tell which variable is for what</p><p><strong>How to fix</strong></p><pre>bbt := bbtPkg.NewBBT(bbtProto.CollectionType_SELF_PICKUP, &quot;PEAK&quot;)<br>collect := collectPkg.New().<br>   WithStatus(bbtProto.NonDelivered)<br>a.UpdateStatus(collect)<br> <br>mn := deduct.New().<br>   WithAccountBalance(totalAmount)<br>a.UpdateMoneyData(mn)</pre><h4>Hardcoded sleep</h4><p><strong>Anti-pattern</strong></p><pre>s.ResetBbtMenu(newFlavour)<br>time.Sleep(30 * time.Second) // hardcoded sleep 30s for reset bbt menu</pre><p><strong>What’s wrong:</strong> Has to wait 30s for each test run</p><pre>s.ResetBbtMenu(newFlavour)<br>found, result := index.AwaitResetMenuUntil(newFlavour, fmt.Sprintf(`&quot;promo_menu&quot;:&quot;%s&quot;`, promoMenu)) // the function will check reset for the promo_menu in every 1s and timeout is 30s.</pre><h4>Hardcoded literals</h4><p><strong>Anti-pattern</strong></p><pre>var wg sync.WaitGroup<br>for i := 0; i &lt; 100; i += 1 {<br>    wg.Add(1)<br>    go doSync(bbtId, &amp;results, &amp;wg)<br>}<br>wg.Wait()</pre><p><strong>What’s wrong: </strong>Hardcoding number of sync tasks</p><p><strong>How to fix</strong></p><pre>var (<br>        ConcurrentDuplicatedSyncTask = 100<br>    )<br>  // ...<br>    var wg sync.WaitGroup<br>    for i := 0; i &lt; ConcurrentDuplicatedSyncTask; i += 1 {<br>        wg.Add(1)<br>        go doSync(bbtId, &amp;results, &amp;wg)<br>    }<br>    wg.Wait()</pre><h4>Using Assert only in test_suites directory</h4><p>assert should only be used in the test file and test case itself, i.e.test_suites/bbt_delivery_test.go . We should avoid using this in other files as it will abuse the purposes of assert method. If we are intend to have a fail alert when the tests is not executing as expected, it should be failed inside a test case, not other places.</p><p>This helps to ensure the failure message is making sense and for ease of debugging.</p><h4>Avoid panic in tests</h4><p>Our principle is to try to avoid using panic in test_suites/, because we are expecting test_suites/ has only pass or fail due to business logic issues. On the other hand, panic is technical terminology, we should avoid the combination of business logic and tech handler (i.e. cannot connect to DB) in test_suites/ .</p><h4>No error handling in tests</h4><p><strong>Anti patterns</strong></p><pre>Test_bbt_delivery(t *testing.T) {<br>    records, err := GetXXFromDB()<br>    if err != nil {// this err is unnecessary and make the code dirty<br>        log.Panic(xx)<br>    }<br>}</pre><p>Avoid such error handling in tests, as this kind of err should be a tech handler but not a business matters.</p><h3>Writing good tests</h3><h4>DOs</h4><h4>Test your tests</h4><p>A good test should fail in case of unexpected product behaviour. A test writer should make sure, if non-obvious, that the test really does fail and there is enough information on failure.</p><p>How to fix</p><p>Perform a modification to cause test to fail</p><ul><li>Environment. For example remove an expected file</li><li>Product itself. For example, hack to return an incorrect value.</li><li>Test. For example, kill a test when it is running and resume</li></ul><p>Verify that the output and/or saved artefacts are good enough for failure analysis</p><p><em>Do not forget to restore the original code.</em></p><h4>When tests fail, ensure they fail properly</h4><h4>Using random data</h4><p><strong>Anti-pattern</strong></p><pre>header := &amp;bbtProto.RequestHeader{}<br>    header.Requestid = proto.String(&quot;test&quot;)<br>    header.DeliveryId = proto.Int64(12345678)</pre><p><strong>What’s wrong:</strong> The request id is very difficult for test debug. Use a timestamp to generate a request id</p><p><strong>How to fix</strong></p><pre>var (<br>        requestId = fmt.Sprintf(&quot;requestId-%d&quot;, time.Now().Unix())<br>        deliveryId = int64(12345678)<br>    )<br> <br>req := &amp;bbtProto.DeliveryRequest{<br>    header := &amp;bbtProto.RequestHeader{}<br>    header.Requestid = proto.String(requestId)<br>    header.DeliveryId = proto.Int64(deliveryId)<br>}</pre><h4>Hiding problem details</h4><p><strong>Anti-pattern</strong></p><pre>func ReadFileToArray(path string) []string {<br>   file, err := os.Open(path)<br>   if err != nil {<br>      log.Println(&quot;unable to open file)<br>      return []string{}<br>   }<br>   defer file.Close()</pre><p><strong>What’s wrong:</strong></p><ul><li>Not reporting file name</li><li>Hiding the inner exception details</li></ul><p>How to fix</p><pre>func ReadFileToArray(path string) []string {<br>   file, err := os.Open(path)<br>   if err != nil {<br>      log.Println(&quot;File name: %s&quot;, path)<br>      log.Println(err.Error())<br>      return []string{}<br>   }<br>   defer file.Close()</pre><h4>Do asserts outside of test case</h4><p>assert.XXX(t, exp, actual)should be done inside test cases. Should not do assert in a common function</p><p><strong>Anti-pattern</strong></p><pre>func CheckUploadCsvReqWithDb(t *testing.T, id uint64, req *admin.UploadCsvRequest) {<br>    dao := db.CsvDao{<br>        Id: id,<br>    }<br>    actual := dao.RetrieveCsvRecord()<br>    assert.Equal(t, req.GetFileName(), actual.GetFileName())<br>    assert.Equal(t, req.GetFileType(), actual.GetFileType())<br>    assert.Equal(t, req.GetLabelId(), actual.GetLabelId())<br>//....<br>}<br> <br> <br>func Test_001(t *testing.T) {<br>    // do something<br>    CheckUploadCsvReqWithDb(t, 123, req)<br>}<br>// ...<br>func Test_005(t *testing.T) {<br>    // do something<br>    CheckUploadCsvReqWithDb(t, 456, req)<br>}</pre><p><strong>What’s wrong</strong></p><ul><li>If the case is failing, we have to jump from here or there to navigate which line of code causes this error. E.g, Test_bbt_delivery_services_peak_hour.go:888 We can quickly go to line 888 to navigate the error. It is inside the test case itself.</li><li>Otherwise, if, say 5 cases use CheckUploadCsvReqWithDb and fail, 5 cases will fail in the same line and it will cause the error context not comprehensive enough.</li></ul><p><strong>How to fix</strong></p><pre>func CheckUploadCsvReqWithDb(id uint64, req *admin.UploadCsvRequest) (result bool, errMsg string) {<br>    dao := db.CsvDao{<br>        Id: id,<br>    }<br>    actual := dao.RetrieveCsvRecord()<br>    if req.GetFileName() != actual.GetFileName() {<br>        return false, fmt.Sprintf(&quot;Expected GetFileName Not Match. Expected GetFileName: %s. Actual GetFileName: %s&quot;, req.GetFileName(), actual.GetFileName())<br>    }<br>    if req.GetFileType() != actual.GetFileType() {<br>        return false, fmt.Sprintf(&quot;Expected GetFileType Not Match. Expected GetFileType: %d. Actual GetFileType: %d&quot;, req.GetFileType(), actual.GetFileType())<br>    }<br> <br>// ...<br>func Test_001(t *testing.T) {<br>    // do something<br>    result, errMsg := CheckUploadCsvReqWithDb(resp.GetId(), req)<br>    assert.True(t, result, errMsg)<br>}<br>// ...<br>func Test_005(t *testing.T) {<br>    // do something<br>    result, errMsg := CheckUploadCsvReqWithDb(resp.GetId(), req)<br>    assert.True(t, result, errMsg)}</pre><h3>Quick Recap</h3><p>In this article, we have discussed:</p><ul><li>Code Review Practices</li><li>Coding Practices — DOs &amp; DONTs</li></ul><p>By leveraging good test development patterns, it could empower better maintainability, clarity, readability and stability in our automated test cases! Cheers! 🎉</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=78820e1802df" width="1" height="1" alt=""><hr><p><a href="https://medium.com/test-go-where/test-development-patterns-and-anti-patterns-78820e1802df">Test Development Patterns and Anti-Patterns</a> was originally published in <a href="https://medium.com/test-go-where">test-go-where</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Merge Request Template Example in Automated Testing]]></title>
            <link>https://medium.com/test-go-where/merge-request-template-example-in-automated-testing-9bcb4675526a?source=rss-ba0af76158fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/9bcb4675526a</guid>
            <category><![CDATA[quality-assurance]]></category>
            <category><![CDATA[automation-testing]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-testing]]></category>
            <category><![CDATA[gitlab]]></category>
            <dc:creator><![CDATA[Hui Ching Lim]]></dc:creator>
            <pubDate>Sun, 15 Nov 2020 13:16:07 GMT</pubDate>
            <atom:updated>2021-08-08T09:07:48.564Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, we will share about one of the best practices that QA Engineering team could develop to ensure the quality of the test scripts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RZxXxBfgDBm1HOyc" /><figcaption>Photo by <a href="https://unsplash.com/@pankajpatel?utm_source=medium&amp;utm_medium=referral">Pankaj Patel</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>WHAT is a MR Template</h3><p><em>Merge Request Template (MR Template)</em> — it’s a checklist for us to ensure our test scripts/code is good to go and also as a ‘QA’ to the test scripts. It’s also a short summary for MR reviewers to know the <strong>story</strong> of this MR and <strong>why do we need the changes</strong>.</p><h3>WHY do QA team need MR Template</h3><p>Not only developers will make mistakes during development, QA could also have mistakes while coding the test scripts.</p><p>By submitting MR template:</p><ul><li>We can prevent contributors from simply merging code that are ‘not elegant’ into the master branch.</li><li>Can get the idea that how teammates design the AT cases. It is similar to test case review process.</li><li>MR template also acts as a reference to each QA’s contribution to the AT repo as the MR contains all the detailed code change information.</li></ul><figure><img alt="https://cdn-images-1.medium.com/max/1600/1*DVry4-z-BwLico6YTb3DKw.png" src="https://cdn-images-1.medium.com/proxy/1*DVry4-z-BwLico6YTb3DKw.png" /></figure><h3>MR Template Example</h3><p><em>This example will be based on coding language </em><em>Go.</em></p><h3>Story</h3><ul><li>[Why do we need this MR? Let your code reviewers to know your story!]</li></ul><p>Summarise your reason of code change in this story section. Basically includes: why, what, how.</p><h3>Test Case Naming</h3><p>✅ Test case name should tell what it is, i.e. Test_{server}_{module}_{function}_{behaviour}</p><p>✅ Should use all lowercase character except the first letter ‘T’</p><p>✅ Test case name should be unique and ‘the only one’ across the AT repo. If you are having test cases: Test_x_y_z [1] &amp; Test_x_y_z_missing_shop_id [2], update the name of [1] to Test_x_y_z_p0 to make it ‘unique’</p><p>Test case naming convention helps to increase the consistency among thousands of cases.</p><p>Test Case Name are always a very important feature point to a test repo. By using snake_casewe can increase the readability, reader can have a rough idea of: ‘what is this test case trying to do’.</p><p>Why not camelCasebut snakeCasefor Test Case Naming? Below article explains subjects can identify the snakeCasestyle more quickly compared to camelCase.</p><p><a href="http://www.cs.kent.edu/~jmaletic/papers/ICPC2010-CamelCaseUnderScoreClouds.pdf">Supporting article</a></p><h3>Product Code Not Merged into Master Yet?</h3><p><a href="http://allegedly.petebevin.com/303.html"><em>The Running of Three-Oh-Three</em></a></p><p>✅ Add TO_BE_UPDATED_AFTER_RELEASE_Test_xxx as prefix to your test cases to skip them for AT Daily Run</p><p>✅ Promise me you won’t forget to update your case name back to normal when your feature code has been merged into master</p><p>Usually we will develop new test scripts that test against new product code. We always want it to merge into AT repo master branch when it’s ready to be merge. This is to prevent the MR is left behind by many commits in master branch (which merge conflicts might occurs).</p><p>But, if:</p><ul><li>Product code has not merged into master yet and our test scripts already be merged into our AT repo master, AT daily run might face failures.</li><li>Hence, adding prefix in test case name could skip them in daily run.</li></ul><p>We should raise another MR to remove the prefix after the product code has goes live/merge into master. This is to ensure our test scripts are always on track with the product master branch.</p><h3>Is Test Passed?</h3><p>✅ Is Test Passed? Make sure your test runs are all passed in the last three times with the same code</p><ul><li>[Provide Your Test Result Here: ]</li></ul><p>To assure the quality of test scripts, we should always make sure test cases in our MR are always ALL-Passed. Provide the evidence of the Jenkins report link. (Honesty are very important as a QA!)</p><p>Avoid using local report as local report might have some settings that only set in the machine, but not in others.(i.e. our golden machine in Jenkins that is used for nightly run)</p><h3>Is Chaos-Proof? (in flavour of chaos Engineering)</h3><p>✅ Kill your test case when it is still running, and then resume, it doesn’t generate any dirty data or fail your second run</p><p>Generally, test scripts will start with preparing the test data for our test execution. When we are having the setup of data, we will need a data clean-up at the end of test execution <em>( a.k.a setup and teardown).</em></p><p>At this point we could simulate the scenario where 1st run is fail to complete/pass the run (i.e. due to network issue), when we give it a retry, it should not fail the 2nd run. <em>(at least not a failures cause by dirty data)</em></p><h3>Avoid Magic Number</h3><p>✅ Instead of using status := proto.Int32(1) , should use status := proto.Int32(yourProtobuf.ACC_STATUS_NORMAL)</p><p>Keep in mind, avoid using such magic number as nobody will knows what does 1 means here except the ‘magician’ who has written this. Probably the ‘magician’ will also doubt what is that magic after a few days. It’s always hard for others to find out the historical of the magic number. — <em>“We DON’T need any magic in Engineering!!”</em></p><h3>Assert Enough?</h3><p>✅ My test cases have enough assert to verify the result (note: it is unacceptable that just simply to verify the response code. You need to verify the return data is as expected)</p><p>Test cases should verify the <strong>correctness of response data</strong>, logic of the requirement. It’s unacceptable to just verify the response code.</p><h3>Method/Variable Naming</h3><p>✅ Use camelCase to name a variable and make it verbs, say, eatAnApple is a good example while eatanapple and eataa are bad</p><ul><li>It is okay to use t, l, k a single alphabet to name a ‘very local variable’ to keep the code tidy</li></ul><p>✅ Use CamelCase to name a method and make it verbs as possible. Just consider all methods are public</p><p>✅ For DB CRUD method, use CreateXXX, RetrieveXXX, UpdateXXX, or DeleteXXX to name them</p><p>✅ For Redis method, use SetXXX, GetXXX, HSetXXX or HGetXXX</p><ul><li>Easier to read eatAnApple vs. eatanapple</li><li>For database CRUD/Redis method we are encourage to use CreateXXX, so that the purpose of this method is self-explanatory.</li></ul><h3>Comment</h3><p>✅ Add comment only when you are really sure your test code can’t tell all of the story (but why?)</p><p>To keep our test scripts tidy and professional, we should only add necessary comment in our test code. Please include the reason if you really need to add in some comment.</p><blockquote>Code is like humor, When you have to explain it, it’s bad.” — Cory House</blockquote><h3>Panic Over Fatal</h3><p>✅ Use log.Panic(YourYellMsg) instead of log.Fatal(YourFatalMsg). This will give you a chance to recover from it if applicable</p><h3>Dependencies Check</h3><p>✅ Run dep ensure -v before MR?</p><p>✅ Review your Gopkg.toml already?</p><p>It’s normal for us accidentally import some wrong/unused dependencies during development of test scripts. We should prevent from keeping those unwanted dependency in our code as it might have failures caused by unknown. Thus, it’s important for us to do the dependencies check.</p><h3>Test Cases should be independent</h3><p>✅ My test case result doesn’t have implicit or explicit dependencies with other test cases</p><p>Each test cases should be able to run, passed individually without the needs of running other test cases first.</p><h3>Beautify Your Code</h3><p>✅ I have run ‘option+command+L’ to format every files involve in this MR</p><p>We should always keep our test scripts tidy and formatted. Above shortcut is to format the code in GoLand. Other IDE should have the function to format the code too.</p><h3>Rule: Your Mom Does NOT Work Here</h3><p>✅ I will not break other people’s test cases.</p><p>Teammates are here to make contribution as a team, making the testing process better and not here to help us to fix the code. Always bear in mind when developing the test scripts, do not break the existing code.</p><h3>When all else fails</h3><p>✅ [List anything you want to mention here:]</p><p>In case there are some rules/practices that fails to follow, please note down here so that reviewers can evaluate case by case.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*eKcS1tyGrgogi2S1" /><figcaption>Photo by <a href="https://unsplash.com/@glenncarstenspeters?utm_source=medium&amp;utm_medium=referral">Glenn Carstens-Peters</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>We have listed down all the best practices that a QA team could follow when submit a MR. Hope this can help test scripts written by QA to be more powerful! (of course, the most important: to make tester’s life easier!)</p><p>Do not forget and try to follow the rules of — <strong>KISS (K</strong>eep <strong>I</strong>t <strong>S</strong>imply and <strong>S</strong>tupid)!</p><p>Stay tuned to our next article! Cheers! 🎉</p><h3>Merge Request Template Example</h3><pre>## Story<br>[Why do we need this MR? Let your code reviewers to know your story!]</pre><pre>## Test Case Naming<br>- [x] Test case name should tell what it is, ```Test_{server}_{module}_{function}_{behavior}```<br>- [] Should use all lowercase character except the first letter &#39;T&#39;<br>- [] Test case name should be unique and &#39;the only one&#39; across the AT repo. If you are having test cases: `Test_x_y_z` [1] &amp; `Test_x_y_z_missing_shop_id` [2], update the name of [1] to `Test_x_y_z_p0` to make it &#39;unique&#39;</pre><pre>## Product Code Not Merged to Master Yet? [The Running of Three-Oh-Three](&lt;http://allegedly.petebevin.com/303.html&gt;)<br>- [ ] Add ```TO_BE_UPDATED_AFTER_RELEASE_Test_xxx``` as prefix to your test cases to skip them for AT Daily Run <br>- [ ] Promise me you won&#39;t forget to update your case name back to normal when your feature code has been merged into master</pre><pre>## Is Test Passed<br>- [ ] Is Test Passed? Make sure your test runs are all passed in the last three times with the same code<br>    - [Provide Your Test Result Here: ]</pre><pre>## Is Chaos-Proof? (in flavour of chaos Engineering)<br>- [ ] Kill your test case when it is still running, and then resume, it doesn&#39;t generate any dirty data or fail your second run<br>    <br>## Avoid Magic Number<br>- [ ] Instead of using `status := proto.Int32(1)` , should use `status := proto.Int32(yourProtobuf.ACC_STATUS_NORMAL)`</pre><pre>## Assert Enough?<br>- [ ] My test cases have enough assert to verify the result (note: it is unacceptable that just simply to verify the response code. You need to verify the return data is as expected)</pre><pre>## Method/Variable Naming<br>- [] Use camelCase to name a variable and make it verbs, say, eatAnApple is a good example while eatanapple and eataa are bad<br>    - it is okay to use t, l, k a single alphabet to name a very local variable to keep the code tidy<br>- [] Use CamelCase to name a method and make it verbs as possible. Just consider all methods are public<br>- [] For DB CRUD method, use ```CreateXXX```, ```RetrieveXXX```, ```UpdateXXX```, or ```DeleteXXX``` to name them <br>- [] For Redis method, use ```SetXXX```, ```GetXXX```, ```HSetXXX``` or ```HGetXXX```</pre><pre># Comment<br>- [] Add comment only when you are really sure your test code can&#39;t tell all of the story (but why?)</pre><pre>## Panic Over Fatal<br>- [] Use ```log.Panic(YourYellMsg)``` instead of ```log.Fatal(YourFatalMsg)```. This will give you a chance to recover from it if applicable</pre><pre>## Dependencies Check<br>- [] Run ```dep ensure -v``` before MR?<br>- [] Review your Gopkg.toml already?</pre><pre>## Test Cases should be independent<br>- [ ] My test case result doesn&#39;t have implicit or explicit dependencies with other test cases</pre><pre>## Beautify Your Code<br>- [] I have run &quot;option+command+L&quot; to format every files involve in this MR</pre><pre>## Rule: [Your Mom Does NOT Work Here](&lt;https://www.facebook.com/alvina.vang/videos/10218785238363679/?extid=VeNau2r6VLLv9hAd&gt;)<br>- [] I will not break other people&#39;s test cases</pre><pre>## When all else fails<br>- [List anything you want to mention here:]</pre><p><em>Additional Info:</em> To have a Merge Request Template (MR Template) in our git repo, can make use of the alternative that GitLab provided which is creating a markdown files as a MR template in our project.</p><p><a href="https://docs.gitlab.com/ee/user/project/description_templates.html#creating-merge-request-templates"><em>Here</em></a><em> are the documentation about MR Template in GitLab.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9bcb4675526a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/test-go-where/merge-request-template-example-in-automated-testing-9bcb4675526a">Merge Request Template Example in Automated Testing</a> was originally published in <a href="https://medium.com/test-go-where">test-go-where</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automated Testing Nightly Run]]></title>
            <link>https://medium.com/test-go-where/automated-testing-nightly-run-c27c804f3bfe?source=rss-ba0af76158fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/c27c804f3bfe</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-testing]]></category>
            <category><![CDATA[quality-assurance]]></category>
            <category><![CDATA[testing-framework]]></category>
            <category><![CDATA[automation-testing]]></category>
            <dc:creator><![CDATA[Hui Ching Lim]]></dc:creator>
            <pubDate>Mon, 09 Nov 2020 14:58:40 GMT</pubDate>
            <atom:updated>2021-08-08T09:11:57.985Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, we will discuss about <strong>What</strong> is <em>‘Nightly Run’</em>, <strong>Why</strong> we need it and <strong>How</strong> does it helps in our testing process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JxjMoa4ocTNPOGgI" /><figcaption>Photo by <a href="https://unsplash.com/@ffstop?utm_source=medium&amp;utm_medium=referral">Fotis Fotopoulos</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3><strong>The Background</strong></h3><p>As a software testing engineer, we often faced many blockers/issues with the testing environment or tools. This causes us have to spend more time on debugging and preparing the environment in order to complete our testing.</p><h3>The Problems</h3><p>Below are some common issues that every software testing engineer should have encountered:</p><ol><li><strong>Very Unstable Test Environment</strong></li></ol><ul><li>Here we have always head to <em>80:20</em> principle, whereby 80% of the time we are getting our test environment to be ready and we execute our testing in the remain 20% of time.</li><li>To adapt Automated Testing (AT), we (QA/testers) must maintain our own AT environment instead of a shared environment across the team or developers. — This is to ensure we are not depending on anyone else.</li></ul><p><strong>2. Regression Testing is Needed Frequently</strong></p><ul><li>When we are doing some product testing, most of the time we are actually doing regression for the main feature logic. It’s obviously a repeated action, and the solution is we can ‘hire’ our ‘AT bot’ to run our scripts every night for free!</li></ul><p><strong>3. Outdated Testing Tools or Scripts</strong></p><ul><li>During testing, we believed everyone will create some tools/test scripts. But do we really maintain and keep it up to date? Probably we just write once and leave it for some time.</li><li>No maintenance for the tool until we need it.</li></ul><p><strong>4. Missing, Left Behind Testing Context/Steps</strong></p><ul><li>Testing context are easily left behind if we do not find some ways to record it down.</li></ul><p><strong>5. Knowledge Transfer (KT) is Needed Across The Team</strong></p><ul><li>Time consuming when we need to do KT among the team, especially the feature or services are brand new to us.</li></ul><h3>What is ‘Nightly Run’ ?</h3><figure><img alt="CI/CD Workflow" src="https://cdn-images-1.medium.com/max/402/1*erRhQrxm8EXfqBfrfAqAHw.png" /></figure><p><strong>Nightly Run, </strong>refer to an automated build which execute every night when no one is working/using the environment.</p><p>Why we need the build to run every night? What will happens during this nightly run?</p><p>Let’s continue to explore together!</p><h3>Why Are the ‘Nightly Run’ Useful to Automation Testing?</h3><p>Of course, it can helps to solve all the problems that we have discussed in previous part of this article! But.. how?</p><p><strong>Unstable/Broken Test Env</strong></p><ul><li>During nightly, each of the server will be re-deploy using the latest code from the master branch of product repo. <em>(*Wow! Such a brand new day!*)</em></li></ul><p><strong>Repeated Regression Testing</strong></p><ul><li>Nightly build helps to run all the test scripts that we have written against the servers automatically. — <em>This can help to detect if there are any code issues after few branches merge into the product master branch. (if any)</em></li></ul><p><em>(Imagine every morning you will have ~1,000 or even more cases executed for us!)</em></p><p><strong>Outdated Testing Tools</strong></p><ul><li>All tools and scripts are converted into automation test cases, which will get execute every night. If the scripts are outdated and we will meet a test failures. <em>(At this point we will know, it needs an updates!)</em></li></ul><p><strong>Missing Test Context</strong></p><ul><li>AT cases should includes data preparation, the result verification and all these can regards as a snapshot of your testing crime scene!</li></ul><p><strong>Knowledge Transfer/ Feature Study is needed</strong></p><ul><li>Helps to save time on conducting feature study sessions, we can always refer to our AT cases to have the knowledge.</li></ul><blockquote>“Software testers do not make software; they only make them better.” — Anonymous</blockquote><h3>Nightly Build</h3><p><em>At this point you should have some knowledge regarding Automation, Jenkins..</em></p><p>What does the Nightly Build 🤖️ do secretly when the world fall asleep…?</p><p>We can have two types of build scheduled periodically every night:</p><ul><li><strong>Server Build</strong> — Which take code from the master branch and starts to build from 9PM onwards.</li><li><strong>Test Scripts Build</strong> — Which take code from the Test Repo <em>(repo maintain by Test engineers) </em>and starts to build from after the last servers build until the next day.</li></ul><p>So.. as a Test Engineer, let’s shout out “Hello World!” to our brand new working day!</p><h3>Nightly Triaging &amp; Email Reporting</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Bfw4u_gYP3Rn9VHG" /><figcaption>Photo by <a href="https://unsplash.com/@ruthson_zimmerman?utm_source=medium&amp;utm_medium=referral">Ruthson Zimmerman</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>After the nightly run, we will need a <strong>Test Report </strong>which includes the status of all the services.</p><p>An Email Report should be send to <strong>team members</strong>, the <strong>Management</strong> <em>(including Tech Leads, Project Manager, QA leads and other related stakeholders).</em></p><p><strong>Step 1: Prepare Nightly Email Reporting — should be the top priority task of the day for Test Engineers.</strong></p><ul><li>Provide prompt AT regression results to all the stakeholders</li><li>Immediate report of any code/services/dependencies failures before we start the day</li></ul><p><strong>Step 2: After we have done preparing of the email report, we should:</strong></p><p><strong>Review service build and deploy failures</strong>, which may caused by:</p><ul><li>Third-party dependencies issue</li><li>Product code defect</li><li>Server config issue</li><li>Intermittent issue (i.e. unstable env, network issues, and etc)</li></ul><p>Review the AT case/scripts failures:</p><ul><li>Outdated AT cases, where there is a code change in product code but the AT scripts have not updated to adapt the changes yet</li><li>Intermittent failures, unstable AT cases, data prep issues and etc</li><li>Test Infrastructure issue, test node service down and etc</li></ul><p><strong>Step 3: After investigation of the failures,</strong> we can reply on top of the Email Report Test Summary about our results of investigation. We should state the fail reason, action to be taken and who are the PIC to resolve the failures.</p><h3>In a Nutshell…</h3><p>Automated Nightly Run is useful for:</p><ul><li><strong>Maintaining</strong> the test environment (ready to use)</li><li>Making the process of testing more <strong>efficient</strong></li><li>Keeping<strong> tools/scripts up to date</strong></li><li>Record the <strong>testing/data preparation steps</strong></li><li>Teammates will eventually get the <strong>knowledge of main features </strong>as we need to review and debug on the failures of nightly.</li><li>Help QA to know where/how can we<strong> to improve our AT cases</strong></li></ul><p>This article introduced one of the good way to make Software Testing Engineer’s testing process easier and efficient.</p><p>Let’s do a little tweak to make our Testing Journey fun! Stay tuned to our new stories! Cheers! 🎉</p><p><em>To know more on how can Jenkins helps to manage Automation Testing:</em></p><p><a href="https://medium.com/automated-testing/jenkins-management-for-automated-testing-continuous-integration-continuous-delivery-and-making-3c93ad256d57">Jenkins Management for Automated Testing — Continuous Integration, Continuous Delivery and Making…</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c27c804f3bfe" width="1" height="1" alt=""><hr><p><a href="https://medium.com/test-go-where/automated-testing-nightly-run-c27c804f3bfe">Automated Testing Nightly Run</a> was originally published in <a href="https://medium.com/test-go-where">test-go-where</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>