4th August 2020

Golang Test Setup

How can I do a test setup by the test package in Golang?

Is there any possible way to do entire test setup processing that is available for every test when utilizing the test package.



public class SuccessTests { 

[SetUp] public void Init()

 { /* Loads the test data */ } }



8th August 2020

Answered by Aryan Sharma

This can be accomplished by placing a init() function within the _test.go file. That will be run ere the init() function. 

package main

 func init() 

{ /* loads the test data */ }



Write your answer


Speak with a Learning Advisor

Understand how the industry and practically oriented courses at Mindmajix transform your career.

  • Explore the trending and niche courses and learning maps
  • Learn about tuition fee, payment plans, and scholarships
  • Get access to webinars and self-paced learning videos