Repository: gofr-dev/gofr

Issue:
consider enabling usetesting linter in golangci-lint
https://golangci-lint.run/usage/linters/#usetesting

https://github.com/ldez/usetesting

Now you are using Go 1.24, we can activate it easily.

257 errors about the usage of [t.Context](https://pkg.go.dev/testing#T.Context)
2 about [t.Setenv](https://pkg.go.dev/testing#T.Setenv)
1 about [t.TempDir](https://pkg.go.dev/testing#T.TempDir)

Discussion:
@yanurag-dev: @ccoVeille  
@vikash I would like to pick this issue.@ccoVeille: I'm fine with it. You can take it.

For records, using `golangci-lint run --enable-only usetesting` locally will report the issues.

You can try  `golangci-lint run --fix --enable-only usetesting` that might fix some of these issues reported

> [!NOTE]
>
> I would like to keep the scope of this PR limited, so please do not try to migrate golangci-lint v2 in this issue
> If you want to do it, then start by migrating to v2 by looking at #1645
> - #1645@ccoVeille: @vikash @Umang01-hash @aryanmehrotra could you assign the issue to @Yadavanurag13 

Thanks@yanurag-dev: @ccoVeille  So If I pick #1645 it will close this too? I'm thinking to migrate linter to v2? wdyt@ccoVeille: It can be done separately.

You can choose to work on the v2 migration too.

But then I would ask you to keep the PR separated. As the number of changes would be too large to review them.

But if you feel confident to migrate to v2, you can try.

But then you will still have to enable usetesting linter for this issue.

Migrating to v2 won't enable usetesting by magic, nor fix the issues this linter might report@yanurag-dev: After adding the usetesting and in .golangci.yaml

`go install github.com/ldez/usetesting/cmd/usetesting@latest`

I'm getting that error mentioned below

```
/dev/fd/13:18: command not found: compdef
anurag@Anurags-MacBook-Air-2 gofr % golangci-lint run --enable-only usetesting
ERRO Can't get config for command line: can't parse args: unknown flag: --enable-only 
anurag@Anurags-MacBook-Air-2 gofr % golangci-lint run --enable=usetesting
Error: can't load config: the Go language version (go1.23) used to build golangci-lint is lower than the targeted Go version (1.24)
Failed executing command with error: can't load config: the Go language version (go1.23) used to build golangci-lint is lower than the targeted Go version (1.24)
anurag@Anurags-MacBook-Air-2 gofr % go install github.com/ldez/usetesting/cmd/usetesting@latest
anurag@Anurags-MacBook-Air-2 gofr % golangci-lint run --enable-only usetesting
ERRO Can't get config for command line: can't parse args: unknown flag: --enable-only 
anurag@Anurags-MacBook-Air-2 gofr % golangci-lint run --enable-only usetesting -c .golangci.yml 
ERRO Can't get config for command line: can't parse args: unknown flag: --enable-only 
anurag@Anurags-MacBook-Air-2 gofr % golangci-lint run --enable-only usetesting -C .golangci.yml
ERRO Can't get config for command line: c
```@ccoVeille: GoFr requires Go 1.24

the minimal version for golangci-lint to work with Go 1.24 is [golangci-lint v1.64.2](https://golangci-lint.run/product/changelog/#v1642)

This version and the few next ones had bugs due to iterative fixes.

The first stable version of golangci-lint with Go 1.24 is [golangci-lint v1.64.7](https://golangci-lint.run/product/changelog/#v1647)

Right now, gofr GitHub worfkow [uses golangci-lint v1.64.X](https://github.com/gofr-dev/gofr/blob/d969729adb26fbf81b3d6d2a5a4d6ba95ff17417/.github/workflows/go.yml#L332)

So it uses the latest one [golangci-lint v1.64.8](https://golangci-lint.run/product/changelog/#v1648)


Based on your error message, I would say the error comes from the fact your golangci-lint local binary is very old.

The fact --enable-only is not available means your version is older than - [golangci-lint v1.57.0](https://golangci-lint.run/product/changelog/#v1570) when --enable-only was added

Please install golangci-lint v1. 64.8 and retry.

Also, for information there is no need to install usetesting locally with `go install ...`

Once you will have golangci-lint a version older than [golangci-lint v1.63.0](https://golangci-lint.run/product/changelog/#v1630), usetesting linter will be available@yanurag-dev: @ccoVeille 

It is stating  configuration version issue. on other setup I have migrated the configuration to v2 and it worked. 

I have latest golangci-lint verion and go 1.24 locally. I don't know why it is not working.

`golangci-lint run
Error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/product/migration-guide for migration instructions
Failed executing command with error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/product/migration-guide for migration instructions`@ccoVeille: The error message seems to be related to a migration problem where the golangci-lint configuration file is not migrated to v2

Did you sort it out by yourself?

As I said in a previous comment, you should try to focus on installing golangci-lint 1.64.8 and focus on the scope of this PR.@yanurag-dev: @ccoVeille Actually, I installed the latest golangci-lint, but there were two versions of Go installed on my machine, and it was using Go 1.23 by default, which caused the issue.

Solution patch:
diff --git a/.golangci.yml b/.golangci.yml
index 3f9388e6..80893be8 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -147,6 +147,9 @@ linters:
     - usestdlibvars
     - whitespace
     - wsl
+    - usetesting
+  
+  
 
   # don't enable:
   # - godox  # Disabling because we need TODO lines at this stage of project.
diff --git a/go.work.sum b/go.work.sum
index 9d8f786e..3c01fd42 100644
--- a/go.work.sum
+++ b/go.work.sum
@@ -1129,4 +1129,4 @@ rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8
 rsc.io/quote/v3 v3.1.0 h1:9JKUTTIUgS6kzR9mK1YuGKv6Nl+DijDNIc0ghT58FaY=
 rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
 rsc.io/sampler v1.3.0 h1:7uVkIFmeBqHfdjD+gZwtXXI+RODJ2Wc4O7MPEh/QiW4=
-rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
+rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
\ No newline at end of file


Test patch:
diff --git a/pkg/gofr/cmd/request_test.go b/pkg/gofr/cmd/request_test.go
index d65510ba..81488ee7 100644
--- a/pkg/gofr/cmd/request_test.go
+++ b/pkg/gofr/cmd/request_test.go
@@ -1,7 +1,6 @@
 package cmd
 
 import (
-	"context"
 	"os"
 	"testing"
 
@@ -44,7 +43,7 @@ func TestRequest_Bind(t *testing.T) {
 
 	osHostName, _ := os.Hostname()
 
-	assert.Equal(t, context.Background(), ctx, "TEST Failed.\n context is not context.Background.")
+	assert.Equal(t, t.Context(), ctx, "TEST Failed.\n context is not context.Background.")
 
 	assert.Equal(t, osHostName, hostName, "TEST Failed.\n Hostname did not match.")
 }
diff --git a/pkg/gofr/cmd/terminal/spinner_test.go b/pkg/gofr/cmd/terminal/spinner_test.go
index bfc0c48a..f3012c38 100644
--- a/pkg/gofr/cmd/terminal/spinner_test.go
+++ b/pkg/gofr/cmd/terminal/spinner_test.go
@@ -13,7 +13,7 @@ import (
 func TestSpinner(t *testing.T) {
 	var (
 		waitTime = 1 * time.Second
-		ctx      = context.TODO()
+		ctx      = t.Context()
 	)
 
 	// Testing Dot spinner
@@ -76,7 +76,7 @@ func TestSpinner_contextDone(t *testing.T) {
 	b := &bytes.Buffer{}
 	out := &Out{out: b}
 	spinner := NewDotSpinner(out)
-	ctx, cancel := context.WithCancel(context.Background())
+	ctx, cancel := context.WithCancel(t.Context())
 
 	// start the spinner
 	spinner.Spin(ctx)
diff --git a/pkg/gofr/config/godotenv_test.go b/pkg/gofr/config/godotenv_test.go
index 6a3e7930..f6393238 100644
--- a/pkg/gofr/config/godotenv_test.go
+++ b/pkg/gofr/config/godotenv_test.go
@@ -95,11 +95,7 @@ func Test_EnvSuccess_SystemEnv_Override(t *testing.T) {
 	// Create the override file
 	createEnvFile(t, dir, ".local.env", map[string]string{"TEST_ENV": "local"})
 
-	// Set system environment variables
-	err := os.Setenv("TEST_ENV", "system")
-	if err != nil {
-		return
-	}
+	t.Setenv("TEST_ENV", "system")
 
 	logger := logging.NewMockLogger(logging.DEBUG)
 
diff --git a/pkg/gofr/container/container_test.go b/pkg/gofr/container/container_test.go
index 4fd5e7a7..4cc282e2 100644
--- a/pkg/gofr/container/container_test.go
+++ b/pkg/gofr/container/container_test.go
@@ -192,17 +192,17 @@ func Test_GetConnectionFromContext(t *testing.T) {
 	}{
 		{
 			name:     "no connection in context",
-			ctx:      context.Background(),
+			ctx:      t.Context(),
 			expected: nil,
 		},
 		{
 			name:     "connection in context",
-			ctx:      context.WithValue(context.Background(), ws.WSConnectionKey, &ws.Connection{Conn: &websocket.Conn{}}),
+			ctx:      context.WithValue(t.Context(), ws.WSConnectionKey, &ws.Connection{Conn: &websocket.Conn{}}),
 			expected: &ws.Connection{Conn: &websocket.Conn{}},
 		},
 		{
 			name:     "wrong type in context",
-			ctx:      context.WithValue(context.Background(), ws.WSConnectionKey, "wrong-type"),
+			ctx:      context.WithValue(t.Context(), ws.WSConnectionKey, "wrong-type"),
 			expected: nil,
 		},
 	}
diff --git a/pkg/gofr/container/health_test.go b/pkg/gofr/container/health_test.go
index 3fc238e1..ef299c8e 100644
--- a/pkg/gofr/container/health_test.go
+++ b/pkg/gofr/container/health_test.go
@@ -108,7 +108,7 @@ func TestContainer_Health(t *testing.T) {
 		c.Services = make(map[string]service.HTTP)
 		c.Services["test-service"] = service.NewHTTPService(srv.URL, logger, nil)
 
-		healthData := c.Health(context.Background())
+		healthData := c.Health(t.Context())
 
 		jsonData, _ := json.Marshal(healthData)
 
diff --git a/pkg/gofr/container/mockcontainer_test.go b/pkg/gofr/container/mockcontainer_test.go
index 38264cf1..bf666b86 100644
--- a/pkg/gofr/container/mockcontainer_test.go
+++ b/pkg/gofr/container/mockcontainer_test.go
@@ -2,7 +2,6 @@ package container
 
 import (
 	"bytes"
-	"context"
 	"net/http/httptest"
 	"testing"
 
@@ -38,11 +37,11 @@ func Test_HttpServiceMock(t *testing.T) {
 	result := res.Result()
 
 	// Setting mock expectations
-	mock.HTTPService.EXPECT().Get(context.Background(), "fact", map[string]any{
+	mock.HTTPService.EXPECT().Get(t.Context(), "fact", map[string]any{
 		"max_length": 20,
 	}).Return(result, nil)
 
-	resp, err := mock.HTTPService.Get(context.Background(), "fact", map[string]any{
+	resp, err := mock.HTTPService.Get(t.Context(), "fact", map[string]any{
 		"max_length": 20,
 	})
 
@@ -64,9 +63,9 @@ func TestExpectSelect_ValidCases(t *testing.T) {
 
 		expectedIDs := []string{"1", "2"}
 
-		mock.SQL.ExpectSelect(context.Background(), &passedResultSlice, "SELECT id FROM users").ReturnsResponse(expectedIDs)
+		mock.SQL.ExpectSelect(t.Context(), &passedResultSlice, "SELECT id FROM users").ReturnsResponse(expectedIDs)
 
-		mockContainer.SQL.Select(context.Background(), &actualResultSlice, "SELECT id FROM users")
+		mockContainer.SQL.Select(t.Context(), &actualResultSlice, "SELECT id FROM users")
 		require.Equal(t, expectedIDs, actualResultSlice)
 	})
 
@@ -76,11 +75,11 @@ func TestExpectSelect_ValidCases(t *testing.T) {
 		expectedIDs := []string{"1", "2"}
 		expectedIDs2 := []string{"1", "3"}
 
-		mock.SQL.ExpectSelect(context.Background(), &passedResultSlice, "SELECT id FROM users").ReturnsResponse(expectedIDs)
-		mock.SQL.ExpectSelect(context.Background(), &passedResultSlice, "SELECT id FROM users").ReturnsResponse(expectedIDs2)
+		mock.SQL.ExpectSelect(t.Context(), &passedResultSlice, "SELECT id FROM users").ReturnsResponse(expectedIDs)
+		mock.SQL.ExpectSelect(t.Context(), &passedResultSlice, "SELECT id FROM users").ReturnsResponse(expectedIDs2)
 
-		mockContainer.SQL.Select(context.Background(), &actualResultSlice, "SELECT id FROM users")
-		mockContainer.SQL.Select(context.Background(), &actualResultSlice2, "SELECT id FROM users")
+		mockContainer.SQL.Select(t.Context(), &actualResultSlice, "SELECT id FROM users")
+		mockContainer.SQL.Select(t.Context(), &actualResultSlice2, "SELECT id FROM users")
 
 		require.Equal(t, expectedIDs, actualResultSlice)
 		require.Equal(t, expectedIDs2, actualResultSlice2)
@@ -96,9 +95,9 @@ func TestExpectSelect_ValidCases(t *testing.T) {
 
 		expectedUser := User{ID: 1, Name: "John"}
 
-		mock.SQL.ExpectSelect(context.Background(), &passedUser, "SELECT * FROM users WHERE id = ?", 1).ReturnsResponse(expectedUser)
+		mock.SQL.ExpectSelect(t.Context(), &passedUser, "SELECT * FROM users WHERE id = ?", 1).ReturnsResponse(expectedUser)
 
-		mockContainer.SQL.Select(context.Background(), &actualUser, "SELECT * FROM users WHERE id = ?", 1)
+		mockContainer.SQL.Select(t.Context(), &actualUser, "SELECT * FROM users WHERE id = ?", 1)
 		require.Equal(t, expectedUser, actualUser)
 	})
 
@@ -107,9 +106,9 @@ func TestExpectSelect_ValidCases(t *testing.T) {
 
 		expectedSettings := map[string]int{"a": 1, "b": 2}
 
-		mock.SQL.ExpectSelect(context.Background(), &passedSettings, "SELECT * FROM settings").ReturnsResponse(expectedSettings)
+		mock.SQL.ExpectSelect(t.Context(), &passedSettings, "SELECT * FROM settings").ReturnsResponse(expectedSettings)
 
-		mockContainer.SQL.Select(context.Background(), &actualSettings, "SELECT * FROM settings")
+		mockContainer.SQL.Select(t.Context(), &actualSettings, "SELECT * FROM settings")
 		require.Equal(t, expectedSettings, actualSettings)
 	})
 }
@@ -130,9 +129,9 @@ func TestExpectSelect_ErrorCases(t *testing.T) {
 
 		expectedVal := 123
 
-		sqlMockWrapper.ExpectSelect(context.Background(), uninitializedVal, "SELECT * FROM test WHERE id=?", 1).ReturnsResponse(expectedVal)
+		sqlMockWrapper.ExpectSelect(t.Context(), uninitializedVal, "SELECT * FROM test WHERE id=?", 1).ReturnsResponse(expectedVal)
 
-		sqlDB.Select(context.Background(), &resultVal, "SELECT * FROM test WHERE id=?", 1)
+		sqlDB.Select(t.Context(), &resultVal, "SELECT * FROM test WHERE id=?", 1)
 		assert.Zero(t, resultVal)
 	})
 
@@ -143,9 +142,9 @@ func TestExpectSelect_ErrorCases(t *testing.T) {
 
 		expectedVal := 123
 
-		sqlMockWrapper.ExpectSelect(context.Background(), &uninitializedVal, "SELECT * FROM test WHERE id=?", 1).ReturnsResponse(&expectedVal)
+		sqlMockWrapper.ExpectSelect(t.Context(), &uninitializedVal, "SELECT * FROM test WHERE id=?", 1).ReturnsResponse(&expectedVal)
 
-		sqlDB.Select(context.Background(), &resultVal, "SELECT * FROM test WHERE id=?", 1)
+		sqlDB.Select(t.Context(), &resultVal, "SELECT * FROM test WHERE id=?", 1)
 		assert.Zero(t, resultVal)
 	})
 
@@ -154,9 +153,9 @@ func TestExpectSelect_ErrorCases(t *testing.T) {
 
 		var expectedVal, resultVal []string
 
-		sqlMockWrapper.ExpectSelect(context.Background(), &expectedVal, "SELECT * FROM test WHERE id=?", 1).ReturnsResponse(123)
+		sqlMockWrapper.ExpectSelect(t.Context(), &expectedVal, "SELECT * FROM test WHERE id=?", 1).ReturnsResponse(123)
 
-		sqlDB.Select(context.Background(), &resultVal, "SELECT * FROM test WHERE id=?", 1)
+		sqlDB.Select(t.Context(), &resultVal, "SELECT * FROM test WHERE id=?", 1)
 		assert.Empty(t, resultVal)
 	})
 
@@ -165,7 +164,7 @@ func TestExpectSelect_ErrorCases(t *testing.T) {
 
 		var val []string
 
-		sqlDB.Select(context.Background(), &val, "SELECT * FROM test WHERE id=?", 1)
+		sqlDB.Select(t.Context(), &val, "SELECT * FROM test WHERE id=?", 1)
 		assert.Empty(t, val)
 	})
 }
diff --git a/pkg/gofr/context_test.go b/pkg/gofr/context_test.go
index 23ab4420..8f0dfe90 100644
--- a/pkg/gofr/context_test.go
+++ b/pkg/gofr/context_test.go
@@ -26,7 +26,7 @@ import (
 )
 
 func Test_newContextSuccess(t *testing.T) {
-	httpRequest, err := http.NewRequestWithContext(context.Background(),
+	httpRequest, err := http.NewRequestWithContext(t.Context(),
 		http.MethodPost, "/test", bytes.NewBufferString(`{"key":"value"}`))
 	httpRequest.Header.Set("Content-Type", "application/json")
 
diff --git a/pkg/gofr/cron_test.go b/pkg/gofr/cron_test.go
index e0e23728..55b5492b 100644
--- a/pkg/gofr/cron_test.go
+++ b/pkg/gofr/cron_test.go
@@ -1,7 +1,6 @@
 package gofr
 
 import (
-	"context"
 	"fmt"
 	"testing"
 	"time"
@@ -326,7 +325,7 @@ func TestJob_tick(t *testing.T) {
 func Test_noopRequest(t *testing.T) {
 	noop := noopRequest{}
 
-	assert.Equal(t, context.Background(), noop.Context())
+	assert.Equal(t, t.Context(), noop.Context())
 	assert.Equal(t, "", noop.Param(""))
 	assert.Empty(t, noop.PathParam(""))
 	assert.Equal(t, "gofr", noop.HostName())
diff --git a/pkg/gofr/datasource/pubsub/google/google_test.go b/pkg/gofr/datasource/pubsub/google/google_test.go
index 481479dc..0afd43d3 100644
--- a/pkg/gofr/datasource/pubsub/google/google_test.go
+++ b/pkg/gofr/datasource/pubsub/google/google_test.go
@@ -34,7 +34,7 @@ func getGoogleClient(t *testing.T) *gcPubSub.Client {
 		t.Errorf("could not initialize a connection to dummy server")
 	}
 
-	client, err := gcPubSub.NewClient(context.Background(), "project", option.WithGRPCConn(conn))
+	client, err := gcPubSub.NewClient(t.Context(), "project", option.WithGRPCConn(conn))
 	if err != nil {
 		t.Errorf("could not initialize a test client")
 	}
@@ -98,7 +98,7 @@ func TestGoogleClient_Publish_Success(t *testing.T) {
 		mockMetrics.EXPECT().IncrementCounter(gomock.Any(), "app_pubsub_publish_total_count", "topic", topic)
 		mockMetrics.EXPECT().IncrementCounter(gomock.Any(), "app_pubsub_publish_success_count", "topic", topic)
 
-		err := g.Publish(context.Background(), topic, message)
+		err := g.Publish(t.Context(), topic, message)
 
 		require.NoError(t, err)
 	})
@@ -122,7 +122,7 @@ func TestGoogleClient_PublishTopic_Error(t *testing.T) {
 	}, metrics: mockMetrics, logger: logging.NewMockLogger(logging.DEBUG)}
 	defer g.client.Close()
 
-	ctx, cancel := context.WithCancel(context.Background())
+	ctx, cancel := context.WithCancel(t.Context())
 
 	cancel()
 
@@ -139,14 +139,14 @@ func TestGoogleClient_getTopic_Success(t *testing.T) {
 	}}
 	defer g.client.Close()
 
-	topic, err := g.getTopic(context.Background(), "test-topic")
+	topic, err := g.getTopic(t.Context(), "test-topic")
 
 	require.NoError(t, err)
 	assert.Equal(t, "test-topic", topic.ID())
 }
 
 func TestGoogleClient_getTopic_Error(t *testing.T) {
-	ctx, cancel := context.WithCancel(context.Background())
+	ctx, cancel := context.WithCancel(t.Context())
 	cancel()
 
 	g := &googleClient{client: getGoogleClient(t), Config: Config{
@@ -168,9 +168,9 @@ func TestGoogleClient_getSubscription(t *testing.T) {
 	}}
 	defer g.client.Close()
 
-	topic, _ := g.client.CreateTopic(context.Background(), "test-topic")
+	topic, _ := g.client.CreateTopic(t.Context(), "test-topic")
 
-	sub, err := g.getSubscription(context.Background(), topic)
+	sub, err := g.getSubscription(t.Context(), topic)
 
 	require.NoError(t, err)
 	assert.NotNil(t, sub)
@@ -229,7 +229,7 @@ func TestGoogleClient_CreateTopic_Success(t *testing.T) {
 			name:      "CreateTopic_Success",
 			topicName: "test-topic",
 			mockBehavior: func() {
-				mockClient.EXPECT().CreateTopic(context.Background(), "test-topic").Return(&gcPubSub.Topic{}, nil)
+				mockClient.EXPECT().CreateTopic(t.Context(), "test-topic").Return(&gcPubSub.Topic{}, nil)
 			},
 			expectedErr: nil,
 		},
@@ -237,7 +237,7 @@ func TestGoogleClient_CreateTopic_Success(t *testing.T) {
 			name:      "CreateTopic_AlreadyExists",
 			topicName: "test-topic",
 			mockBehavior: func() {
-				mockClient.EXPECT().CreateTopic(context.Background(), "test-topic").Return(&gcPubSub.Topic{}, errTopicExists)
+				mockClient.EXPECT().CreateTopic(t.Context(), "test-topic").Return(&gcPubSub.Topic{}, errTopicExists)
 			},
 			expectedErr: errTopicExists,
 		},
@@ -247,7 +247,7 @@ func TestGoogleClient_CreateTopic_Success(t *testing.T) {
 		t.Run(tt.name, func(t *testing.T) {
 			tt.mockBehavior()
 
-			err := g.CreateTopic(context.Background(), tt.topicName)
+			err := g.CreateTopic(t.Context(), tt.topicName)
 
 			require.ErrorIs(t, err, tt.expectedErr, "expected no error, but got one")
 		})
@@ -261,10 +261,10 @@ func TestGoogleClient_CreateTopic_Error(t *testing.T) {
 	mockClient := NewMockClient(ctrl)
 	g := &googleClient{client: mockClient, Config: Config{ProjectID: "test", SubscriptionName: "sub"}}
 
-	mockClient.EXPECT().CreateTopic(context.Background(), "test-topic").
+	mockClient.EXPECT().CreateTopic(t.Context(), "test-topic").
 		Return(&gcPubSub.Topic{}, errTestSentinel)
 
-	err := g.CreateTopic(context.Background(), "test-topic")
+	err := g.CreateTopic(t.Context(), "test-topic")
 
 	require.ErrorIs(t, err, errTestSentinel, "expected test-error but got different error")
 }
@@ -275,13 +275,13 @@ func TestGoogleClient_CreateTopic_EmptyClient(t *testing.T) {
 
 	g := &googleClient{client: nil, Config: Config{ProjectID: "test", SubscriptionName: "sub"}}
 
-	err := g.CreateTopic(context.Background(), "test-topic")
+	err := g.CreateTopic(t.Context(), "test-topic")
 
 	require.ErrorIs(t, err, errClientNotConnected, "expected client-error but got different error")
 }
 
 func TestGoogleClient_DeleteTopic(t *testing.T) {
-	ctx := context.Background()
+	ctx := t.Context()
 
 	client := getGoogleClient(t)
 	defer client.Close()
@@ -311,7 +311,7 @@ func TestGoogleClient_DeleteTopic_EmptyClient(t *testing.T) {
 
 	g := &googleClient{client: nil, Config: Config{ProjectID: "test", SubscriptionName: "sub"}}
 
-	err := g.DeleteTopic(context.Background(), "test-topic")
+	err := g.DeleteTopic(t.Context(), "test-topic")
 
 	require.ErrorIs(t, err, errClientNotConnected, "expected client-error but got different error")
 }
diff --git a/pkg/gofr/datasource/pubsub/kafka/kafka_test.go b/pkg/gofr/datasource/pubsub/kafka/kafka_test.go
index 24fe1ca5..d0fe13dc 100644
--- a/pkg/gofr/datasource/pubsub/kafka/kafka_test.go
+++ b/pkg/gofr/datasource/pubsub/kafka/kafka_test.go
@@ -1,7 +1,6 @@
 package kafka
 
 import (
-	"context"
 	"errors"
 	"sync"
 	"testing"
@@ -201,7 +200,7 @@ func TestKafkaClient_PublishError(t *testing.T) {
 	mockWriter := NewMockWriter(ctrl)
 	mockMetrics := NewMockMetrics(ctrl)
 	k := &kafkaClient{writer: mockWriter, metrics: mockMetrics}
-	ctx := context.TODO()
+	ctx := t.Context()
 
 	testCases := []struct {
 		desc      string
@@ -260,7 +259,7 @@ func TestKafkaClient_Publish(t *testing.T) {
 	mockMetrics := NewMockMetrics(ctrl)
 
 	logs := testutil.StdoutOutputForFunc(func() {
-		ctx := context.TODO()
+		ctx := t.Context()
 		logger := logging.NewMockLogger(logging.DEBUG)
 		k := &kafkaClient{writer: mockWriter, logger: logger, metrics: mockMetrics}
 
@@ -288,7 +287,7 @@ func TestKafkaClient_SubscribeSuccess(t *testing.T) {
 	ctrl := gomock.NewController(t)
 	defer ctrl.Finish()
 
-	ctx := context.TODO()
+	ctx := t.Context()
 	mockReader := NewMockReader(ctrl)
 	mockMetrics := NewMockMetrics(ctrl)
 	mockConnection := NewMockConnection(ctrl)
@@ -358,7 +357,7 @@ func TestKafkaClient_Subscribe_ErrConsumerGroupID(t *testing.T) {
 
 	mockConnection.EXPECT().Controller().Return(kafka.Broker{}, nil)
 
-	msg, err := k.Subscribe(context.TODO(), "test")
+	msg, err := k.Subscribe(t.Context(), "test")
 	assert.NotNil(t, msg)
 	assert.Equal(t, ErrConsumerGroupNotProvided, err)
 }
@@ -373,7 +372,7 @@ func TestKafkaClient_SubscribeError(t *testing.T) {
 	ctrl := gomock.NewController(t)
 	defer ctrl.Finish()
 
-	ctx := context.TODO()
+	ctx := t.Context()
 	mockReader := NewMockReader(ctrl)
 	mockMetrics := NewMockMetrics(ctrl)
 	mockConnection := NewMockConnection(ctrl)
@@ -571,7 +570,7 @@ func TestKafkaClient_DeleteTopic(t *testing.T) {
 
 	mockClient.EXPECT().DeleteTopics("test").Return(nil)
 
-	err := client.DeleteTopic(context.Background(), "test")
+	err := client.DeleteTopic(t.Context(), "test")
 
 	require.NoError(t, err)
 }
@@ -596,7 +595,7 @@ func TestKafkaClient_CreateTopic(t *testing.T) {
 	for _, tc := range testCases {
 		mockClient.EXPECT().CreateTopics(gomock.Any()).Return(tc.err)
 
-		err := client.CreateTopic(context.Background(), "test")
+		err := client.CreateTopic(t.Context(), "test")
 
 		assert.Equal(t, tc.err, err)
 	}
@@ -611,7 +610,7 @@ func TestKafkaClient_Subscribe_NotConnected(t *testing.T) {
 	ctrl := gomock.NewController(t)
 	defer ctrl.Finish()
 
-	ctx := context.TODO()
+	ctx := t.Context()
 	mockConnection := NewMockConnection(ctrl)
 
 	k := &kafkaClient{
diff --git a/pkg/gofr/datasource/pubsub/message_test.go b/pkg/gofr/datasource/pubsub/message_test.go
index dbc177bd..88cd721b 100644
--- a/pkg/gofr/datasource/pubsub/message_test.go
+++ b/pkg/gofr/datasource/pubsub/message_test.go
@@ -1,7 +1,6 @@
 package pubsub
 
 import (
-	"context"
 	"testing"
 
 	"github.com/stretchr/testify/assert"
@@ -9,7 +8,7 @@ import (
 )
 
 func TestMessage_Context(t *testing.T) {
-	ctx := context.Background()
+	ctx := t.Context()
 	m := NewMessage(ctx)
 
 	out := m.Context()
@@ -85,7 +84,7 @@ func TestMessage_Bind(t *testing.T) {
 
 	for _, tc := range testCases {
 		t.Run(tc.desc, func(t *testing.T) {
-			m := NewMessage(context.Background())
+			m := NewMessage(t.Context())
 			m.Value = tc.value
 
 			err := m.Bind(tc.input)
@@ -191,7 +190,7 @@ func TestMessage_Param(t *testing.T) {
 		{desc: "any other param is fetched", input: "path", expectedOut: ""},
 	}
 
-	m := NewMessage(context.TODO())
+	m := NewMessage(t.Context())
 	m.Topic = "test-topic"
 
 	for _, tc := range testCases {
@@ -211,7 +210,7 @@ func TestMessage_PathParam(t *testing.T) {
 		{desc: "other path param is fetched", input: "path", expectedOut: ""},
 	}
 
-	m := NewMessage(context.TODO())
+	m := NewMessage(t.Context())
 	m.Topic = "test-topic"
 
 	for _, tc := range testCases {
diff --git a/pkg/gofr/datasource/pubsub/mqtt/mqtt_test.go b/pkg/gofr/datasource/pubsub/mqtt/mqtt_test.go
index cc7081ef..a01db330 100644
--- a/pkg/gofr/datasource/pubsub/mqtt/mqtt_test.go
+++ b/pkg/gofr/datasource/pubsub/mqtt/mqtt_test.go
@@ -1,7 +1,6 @@
 package mqtt
 
 import (
-	"context"
 	"errors"
 	"net/url"
 	"sync"
@@ -124,7 +123,7 @@ func TestMQTT_Disconnect(t *testing.T) {
 	ctrl, client, mockClient, mockMetrics, mockToken := getMockMQTT(t, mockConfigs)
 	defer ctrl.Finish()
 
-	ctx := context.Background()
+	ctx := t.Context()
 
 	mockMetrics.EXPECT().
 		IncrementCounter(ctx, "app_pubsub_publish_total_count", "topic", "test")
@@ -173,7 +172,7 @@ func TestMQTT_PublishSuccess(t *testing.T) {
 		ctrl, client, mockClient, mockMetrics, mockToken := getMockMQTT(t, mockConfigs)
 		defer ctrl.Finish()
 
-		ctx := context.Background()
+		ctx := t.Context()
 
 		mockMetrics.EXPECT().
 			IncrementCounter(ctx, "app_pubsub_publish_total_count", "topic", "test/topic")
@@ -201,7 +200,7 @@ func TestMQTT_PublishFailure(t *testing.T) {
 	ctrl, client, mockClient, mockMetrics, mockToken := getMockMQTT(t, mockConfigs)
 	defer ctrl.Finish()
 
-	ctx := context.Background()
+	ctx := t.Context()
 	// case where the client has been disconnected, resulting in a Publishing failure
 	mockMetrics.EXPECT().
 		IncrementCounter(ctx, "app_pubsub_publish_total_count", "topic", "test/topic")
@@ -224,7 +223,7 @@ func TestMQTT_SubscribeSuccess(t *testing.T) {
 	ctrl, client, mockClient, mockMetrics, mockToken := getMockMQTT(t, mockConfigs)
 	defer ctrl.Finish()
 
-	ctx := context.Background()
+	ctx := t.Context()
 
 	mockMetrics.EXPECT().
 		IncrementCounter(gomock.Any(), "app_pubsub_subscribe_success_count", "topic", "test/topic")
@@ -253,7 +252,7 @@ func TestMQTT_SubscribeFailure(t *testing.T) {
 	ctrl, client, mockClient, _, mockToken := getMockMQTT(t, mockConfigs)
 	defer ctrl.Finish()
 
-	ctx := context.Background()
+	ctx := t.Context()
 
 	mockClient.EXPECT().IsConnected().Return(true)
 	mockClient.EXPECT().Subscribe("test/topic", mockConfigs.QoS, gomock.Any()).Return(mockToken)
@@ -379,7 +378,7 @@ func TestMQTT_CreateTopic(t *testing.T) {
 		mockToken.EXPECT().Wait().Return(true)
 		mockToken.EXPECT().Error().Return(nil)
 
-		err := client.CreateTopic(context.Background(), "test/topic")
+		err := client.CreateTopic(t.Context(), "test/topic")
 		require.NoError(t, err)
 
 		// Failure case
@@ -392,7 +391,7 @@ func TestMQTT_CreateTopic(t *testing.T) {
 		mockToken.EXPECT().Wait().Return(true)
 		mockToken.EXPECT().Error().Return(errToken).Times(3)
 
-		err = client.CreateTopic(context.Background(), "test/topic")
+		err = client.CreateTopic(t.Context(), "test/topic")
 		require.Error(t, err)
 	})
 
@@ -446,7 +445,7 @@ func TestMQTT_Health(t *testing.T) {
 func TestMQTT_DeleteTopic(t *testing.T) {
 	m := &MQTT{}
 
-	err := m.DeleteTopic(context.Background(), "test/topic")
+	err := m.DeleteTopic(t.Context(), "test/topic")
 	require.NoError(t, err)
 }
 
@@ -541,7 +540,7 @@ func TestMQTT_createMqttHandler(t *testing.T) {
 
 			mockMetrics.EXPECT().IncrementCounter(gomock.Any(), "app_pubsub_subscribe_total_count", "topic", "test/topic")
 
-			handler := client.createMqttHandler(context.Background(), "test/topic", msgs)
+			handler := client.createMqttHandler(t.Context(), "test/topic", msgs)
 
 			handler(nil, mockMessage{false, 1, false, "test/topic", 123, "hello world"})
 		})
diff --git a/pkg/gofr/datasource/redis/redis_test.go b/pkg/gofr/datasource/redis/redis_test.go
index 0da3ea2f..57beeb23 100644
--- a/pkg/gofr/datasource/redis/redis_test.go
+++ b/pkg/gofr/datasource/redis/redis_test.go
@@ -1,7 +1,6 @@
 package redis
 
 import (
-	"context"
 	"testing"
 	"time"
 
@@ -65,7 +64,7 @@ func TestRedis_QueryLogging(t *testing.T) {
 
 		require.NoError(t, err)
 
-		result, err := client.Set(context.TODO(), "key", "value", 1*time.Minute).Result()
+		result, err := client.Set(t.Context(), "key", "value", 1*time.Minute).Result()
 
 		require.NoError(t, err)
 		assert.Equal(t, "OK", result)
@@ -102,11 +101,11 @@ func TestRedis_PipelineQueryLogging(t *testing.T) {
 
 		// Pipeline execution
 		pipe := client.Pipeline()
-		setCmd := pipe.Set(context.TODO(), "key1", "value1", 1*time.Minute)
-		getCmd := pipe.Get(context.TODO(), "key1")
+		setCmd := pipe.Set(t.Context(), "key1", "value1", 1*time.Minute)
+		getCmd := pipe.Get(t.Context(), "key1")
 
 		// Pipeline Exec should return a non-nil error
-		_, err = pipe.Exec(context.TODO())
+		_, err = pipe.Exec(t.Context())
 		require.NoError(t, err)
 
 		// Retrieve results
diff --git a/pkg/gofr/datasource/sql/db_test.go b/pkg/gofr/datasource/sql/db_test.go
index c5e3b067..ebebb262 100644
--- a/pkg/gofr/datasource/sql/db_test.go
+++ b/pkg/gofr/datasource/sql/db_test.go
@@ -53,7 +53,7 @@ func TestDB_SelectSingleColumnFromIntToString(t *testing.T) {
 		gomock.Any(), "hostname", gomock.Any(), "database", gomock.Any(), "type", gomock.Any())
 
 	ids := make([]string, 0)
-	db.Select(context.TODO(), &ids, "select id from users")
+	db.Select(t.Context(), &ids, "select id from users")
 
 	assert.Equal(t, []string{"1", "2"}, ids, "TEST Failed.\n")
 }
@@ -75,7 +75,7 @@ func TestDB_SelectSingleColumnFromStringToString(t *testing.T) {
 		gomock.Any(), "hostname", gomock.Any(), "database", gomock.Any(), "type", gomock.Any())
 
 	ids := make([]string, 0)
-	db.Select(context.TODO(), &ids, "select id from users")
+	db.Select(t.Context(), &ids, "select id from users")
 
 	assert.Equal(t, []string{"1", "2"}, ids, "TEST Failed.\n")
 }
@@ -97,7 +97,7 @@ func TestDB_SelectSingleColumnFromIntToInt(t *testing.T) {
 		gomock.Any(), "hostname", gomock.Any(), "database", gomock.Any(), "type", gomock.Any())
 
 	ids := make([]int, 0)
-	db.Select(context.TODO(), &ids, "select id from users")
+	db.Select(t.Context(), &ids, "select id from users")
 
 	assert.Equal(t, []int{1, 2}, ids, "TEST Failed.\n")
 }
@@ -122,7 +122,7 @@ func TestDB_SelectSingleColumnFromIntToCustomInt(t *testing.T) {
 
 	ids := make([]CustomInt, 0)
 
-	db.Select(context.TODO(), &ids, "select id from users")
+	db.Select(t.Context(), &ids, "select id from users")
 
 	assert.Equal(t, []CustomInt{1, 2}, ids, "TEST Failed.\n")
 }
@@ -147,13 +147,13 @@ func TestDB_SelectSingleColumnFromStringToCustomInt(t *testing.T) {
 
 	ids := make([]CustomInt, 0)
 
-	db.Select(context.TODO(), &ids, "select id from users")
+	db.Select(t.Context(), &ids, "select id from users")
 
 	assert.Equal(t, []CustomInt{1, 2}, ids, "TEST Failed.\n")
 }
 
 func TestDB_SelectContextError(t *testing.T) {
-	ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(time.Microsecond))
+	ctx, cancel := context.WithDeadline(t.Context(), time.Now().Add(time.Microsecond))
 	time.Sleep(1 * time.Millisecond)
 
 	defer cancel()
@@ -170,7 +170,7 @@ func TestDB_SelectDataPointerError(t *testing.T) {
 		db, _ := getDB(t, logging.INFO)
 		defer db.DB.Close()
 
-		db.Select(context.Background(), nil, "select 1")
+		db.Select(t.Context(), nil, "select 1")
 	})
 
 	assert.Contains(t, out, "we did not get a pointer. data is not settable.", "TEST Failed.\n")
@@ -196,7 +196,7 @@ func TestDB_SelectSingleColumnFromStringToCustomString(t *testing.T) {
 
 	ids := make([]CustomStr, 0)
 
-	db.Select(context.TODO(), &ids, "select id from users")
+	db.Select(t.Context(), &ids, "select id from users")
 
 	assert.Equal(t, []CustomStr{"1", "2"}, ids, "TEST Failed.\n")
 }
@@ -224,7 +224,7 @@ func TestDB_SelectSingleRowMultiColumn(t *testing.T) {
 
 	u := user{}
 
-	db.Select(context.TODO(), &u, "select 1 user")
+	db.Select(t.Context(), &u, "select 1 user")
 
 	assert.Equal(t, user{
 		Name:  "Vikash",
@@ -256,7 +256,7 @@ func TestDB_SelectSingleRowMultiColumnWithTags(t *testing.T) {
 
 	u := user{}
 
-	db.Select(context.TODO(), &u, "select 1 user")
+	db.Select(t.Context(), &u, "select 1 user")
 
 	assert.Equal(t, user{
 		Name:  "Vikash",
@@ -289,7 +289,7 @@ func TestDB_SelectMultiRowMultiColumnWithTags(t *testing.T) {
 
 	users := []user{}
 
-	db.Select(context.TODO(), &users, "select users")
+	db.Select(t.Context(), &users, "select users")
 
 	assert.Equal(t, []user{
 		{
@@ -320,7 +320,7 @@ func TestDB_SelectSingleColumnError(t *testing.T) {
 		mockMetrics.EXPECT().RecordHistogram(gomock.Any(), "app_sql_stats",
 			gomock.Any(), "hostname", gomock.Any(), "database", gomock.Any(), "type", gomock.Any())
 
-		db.Select(context.TODO(), &ids, "select id from users")
+		db.Select(t.Context(), &ids, "select id from users")
 	})
 
 	assert.Contains(t, out, "DB error", "TEST Failed.\n")
@@ -335,7 +335,7 @@ func TestDB_SelectDataPointerNotExpected(t *testing.T) {
 		db, _ := getDB(t, logging.DEBUG)
 		defer db.DB.Close()
 
-		db.Select(context.Background(), &m, "select id from users")
+		db.Select(t.Context(), &m, "select id from users")
 	})
 
 	assert.Contains(t, out, "a pointer to map was not expected.", "TEST Failed.\n")
@@ -422,7 +422,7 @@ func TestDB_QueryContext(t *testing.T) {
 		mockMetrics.EXPECT().RecordHistogram(gomock.Any(), "app_sql_stats",
 			gomock.Any(), "hostname", gomock.Any(), "database", gomock.Any(), "type", "SELECT")
 
-		rows, err = db.QueryContext(context.Background(), "SELECT 1")
+		rows, err = db.QueryContext(t.Context(), "SELECT 1")
 		require.NoError(t, err)
 		require.NoError(t, rows.Err())
 		assert.NotNil(t, rows)
@@ -451,7 +451,7 @@ func TestDB_QueryContextError(t *testing.T) {
 		mockMetrics.EXPECT().RecordHistogram(gomock.Any(), "app_sql_stats",
 			gomock.Any(), "hostname", gomock.Any(), "database", gomock.Any(), "type", "SELECT")
 
-		rows, err = db.QueryContext(context.Background(), "SELECT")
+		rows, err = db.QueryContext(t.Context(), "SELECT")
 		if !assert.Nil(t, rows) {
 			require.NoError(t, rows.Err())
 		}
@@ -507,7 +507,7 @@ func TestDB_QueryRowContext(t *testing.T) {
 		mockMetrics.EXPECT().RecordHistogram(gomock.Any(), "app_sql_stats",
 			gomock.Any(), "hostname", gomock.Any(), "database", gomock.Any(), "type", "SELECT")
 
-		row = db.QueryRowContext(context.Background(), "SELECT name FROM employee WHERE id = ?", 1)
+		row = db.QueryRowContext(t.Context(), "SELECT name FROM employee WHERE id = ?", 1)
 		assert.NotNil(t, row)
 	})
 
@@ -591,7 +591,7 @@ func TestDB_ExecContext(t *testing.T) {
 		mockMetrics.EXPECT().RecordHistogram(gomock.Any(), "app_sql_stats",
 			gomock.Any(), "hostname", gomock.Any(), "database", gomock.Any(), "type", "INSERT")
 
-		res, err = db.ExecContext(context.Background(), "INSERT INTO employee VALUES(?, ?)", 2, "doe")
+		res, err = db.ExecContext(t.Context(), "INSERT INTO employee VALUES(?, ?)", 2, "doe")
 		require.NoError(t, err)
 		assert.NotNil(t, res)
 	})
@@ -619,7 +619,7 @@ func TestDB_ExecContextError(t *testing.T) {
 		mockMetrics.EXPECT().RecordHistogram(gomock.Any(), "app_sql_stats",
 			gomock.Any(), "hostname", gomock.Any(), "database", gomock.Any(), "type", "INSERT")
 
-		res, err = db.ExecContext(context.Background(), "INSERT INTO employee VALUES(?, ?)", 2, "doe")
+		res, err = db.ExecContext(t.Context(), "INSERT INTO employee VALUES(?, ?)", 2, "doe")
 		require.NoError(t, err)
 		assert.NotNil(t, res)
 	})
@@ -834,7 +834,7 @@ func TestTx_QueryRowContext(t *testing.T) {
 		mockMetrics.EXPECT().RecordHistogram(gomock.Any(), "app_sql_stats",
 			gomock.Any(), "hostname", gomock.Any(), "database", gomock.Any(), "type", "SELECT")
 
-		row = tx.QueryRowContext(context.Background(), "SELECT name FROM employee WHERE id = ?", 1)
+		row = tx.QueryRowContext(t.Context(), "SELECT name FROM employee WHERE id = ?", 1)
 		assert.NotNil(t, row)
 	})
 
@@ -924,7 +924,7 @@ func TestTx_ExecContext(t *testing.T) {
 		mockMetrics.EXPECT().RecordHistogram(gomock.Any(), "app_sql_stats",
 			gomock.Any(), "hostname", gomock.Any(), "database", gomock.Any(), "type", "INSERT")
 
-		res, err = tx.ExecContext(context.Background(), "INSERT INTO employee VALUES(?, ?)", 2, "doe")
+		res, err = tx.ExecContext(t.Context(), "INSERT INTO employee VALUES(?, ?)", 2, "doe")
 		require.NoError(t, err)
 		assert.NotNil(t, res)
 	})
@@ -954,7 +954,7 @@ func TestTx_ExecContextError(t *testing.T) {
 		mockMetrics.EXPECT().RecordHistogram(gomock.Any(), "app_sql_stats",
 			gomock.Any(), "hostname", gomock.Any(), "database", gomock.Any(), "type", "INSERT")
 
-		res, err = tx.ExecContext(context.Background(), "INSERT INTO employee VALUES(?, ?)", 2, "doe")
+		res, err = tx.ExecContext(t.Context(), "INSERT INTO employee VALUES(?, ?)", 2, "doe")
 		require.NoError(t, err)
 		assert.NotNil(t, res)
 	})
diff --git a/pkg/gofr/exporter_test.go b/pkg/gofr/exporter_test.go
index 71a43626..7200dc3b 100644
--- a/pkg/gofr/exporter_test.go
+++ b/pkg/gofr/exporter_test.go
@@ -33,7 +33,7 @@ func Test_ExportSpans(t *testing.T) {
 	}
 
 	for i, tc := range tests {
-		err := exporter.ExportSpans(context.Background(), tc.spans)
+		err := exporter.ExportSpans(t.Context(), tc.spans)
 
 		require.NoError(t, err, "TEST[%d], Failed.\n%s", i, tc.desc)
 	}
@@ -46,7 +46,7 @@ func Test_ExportSpansError(t *testing.T) {
 
 	exporter := NewExporter(server.URL, logging.NewLogger(logging.INFO))
 
-	err := exporter.ExportSpans(context.Background(), provideSampleSpan(t))
+	err := exporter.ExportSpans(t.Context(), provideSampleSpan(t))
 	require.Error(t, err, "Expected error for failed request")
 }
 
@@ -60,13 +60,13 @@ func provideSampleSpan(t *testing.T) []sdktrace.ReadOnlySpan {
 		if err != nil {
 			t.Error(err)
 		}
-	}(tp, context.Background())
+	}(tp, t.Context())
 
 	otel.SetTracerProvider(tp)
 
 	tracer := otel.Tracer("test-tracer")
 
-	_, span := tracer.Start(context.Background(), "test-span")
+	_, span := tracer.Start(t.Context(), "test-span")
 	span.End()
 
 	ro := span.(sdktrace.ReadOnlySpan)
diff --git a/pkg/gofr/gofr_test.go b/pkg/gofr/gofr_test.go
index a29d1f1f..970987f5 100644
--- a/pkg/gofr/gofr_test.go
+++ b/pkg/gofr/gofr_test.go
@@ -1,7 +1,6 @@
 package gofr
 
 import (
-	"context"
 	"encoding/base64"
 	"encoding/json"
 	"fmt"
@@ -216,7 +215,7 @@ func TestGofr_ServerRun(t *testing.T) {
 		Timeout: 200 * time.Millisecond,
 	}
 
-	re, _ := http.NewRequestWithContext(context.Background(), http.MethodGet,
+	re, _ := http.NewRequestWithContext(t.Context(), http.MethodGet,
 		"http://localhost:"+fmt.Sprint(configs.HTTPPort)+"/hello", http.NoBody)
 	resp, err := netClient.Do(re)
 
@@ -241,7 +240,7 @@ func Test_AddHTTPService(t *testing.T) {
 	g.AddHTTPService("test-service", server.URL)
 
 	resp, _ := g.container.GetHTTPService("test-service").
-		Get(context.Background(), "test", nil)
+		Get(t.Context(), "test", nil)
 
 	defer resp.Body.Close()
 
@@ -378,7 +377,7 @@ func TestEnableBasicAuthWithFunc(t *testing.T) {
 	client := server.Client()
 
 	// Create a mock HTTP request
-	req, err := http.NewRequestWithContext(context.Background(), http.MethodGet, server.URL, http.NoBody)
+	req, err := http.NewRequestWithContext(t.Context(), http.MethodGet, server.URL, http.NoBody)
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -470,7 +469,7 @@ func Test_EnableBasicAuth(t *testing.T) {
 			client := server.Client()
 
 			// Create a mock HTTP request
-			req, err := http.NewRequestWithContext(context.Background(), http.MethodGet, server.URL, http.NoBody)
+			req, err := http.NewRequestWithContext(t.Context(), http.MethodGet, server.URL, http.NoBody)
 			require.NoError(t, err)
 
 			// Add a basic authorization header
@@ -541,7 +540,7 @@ func Test_EnableBasicAuthWithValidator(t *testing.T) {
 			client := server.Client()
 
 			// Create a mock HTTP request
-			req, err := http.NewRequestWithContext(context.Background(), http.MethodGet, server.URL, http.NoBody)
+			req, err := http.NewRequestWithContext(t.Context(), http.MethodGet, server.URL, http.NoBody)
 			require.NoError(t, err)
 
 			// Add a basic authorization header
@@ -714,7 +713,7 @@ func Test_UseMiddleware(t *testing.T) {
 		Timeout: 200 * time.Millisecond,
 	}
 
-	req, _ := http.NewRequestWithContext(context.Background(), http.MethodGet,
+	req, _ := http.NewRequestWithContext(t.Context(), http.MethodGet,
 		fmt.Sprintf("http://localhost:%d", port)+"/test", http.NoBody)
 
 	resp, err := netClient.Do(req)
@@ -819,7 +818,7 @@ func Test_APIKeyAuthMiddleware(t *testing.T) {
 		Timeout: 200 * time.Millisecond,
 	}
 
-	req, _ := http.NewRequestWithContext(context.Background(), http.MethodGet,
+	req, _ := http.NewRequestWithContext(t.Context(), http.MethodGet,
 		fmt.Sprintf("http://localhost:%d", port)+"/test", http.NoBody)
 	req.Header.Set("X-Api-Key", "test-key")
 
@@ -865,7 +864,7 @@ func Test_SwaggerEndpoints(t *testing.T) {
 		Timeout: 200 * time.Millisecond,
 	}
 
-	re, _ := http.NewRequestWithContext(context.Background(), http.MethodGet,
+	re, _ := http.NewRequestWithContext(t.Context(), http.MethodGet,
 		configs.HTTPHost+"/.well-known/swagger", http.NoBody)
 	resp, err := netClient.Do(re)
 
@@ -981,7 +980,7 @@ func TestStaticHandler(t *testing.T) {
 	}
 
 	for i, tc := range tests {
-		request, err := http.NewRequestWithContext(context.Background(), tc.method, host+tc.path, http.NoBody)
+		request, err := http.NewRequestWithContext(t.Context(), tc.method, host+tc.path, http.NoBody)
 		if err != nil {
 			t.Fatalf("TEST[%d], Failed to create request, error: %s", i, err)
 		}
@@ -1078,7 +1077,7 @@ func Test_Shutdown(t *testing.T) {
 		go g.Run()
 		time.Sleep(10 * time.Millisecond)
 
-		err := g.Shutdown(context.Background())
+		err := g.Shutdown(t.Context())
 
 		require.NoError(t, err, "Test_Shutdown Failed!")
 	})
diff --git a/pkg/gofr/grpc_test.go b/pkg/gofr/grpc_test.go
index 42cb08e9..7ee9fb29 100644
--- a/pkg/gofr/grpc_test.go
+++ b/pkg/gofr/grpc_test.go
@@ -64,7 +64,7 @@ func TestGRPC_ServerRun(t *testing.T) {
 			// Give some time for the server to attempt startup
 			time.Sleep(500 * time.Millisecond)
 
-			_ = g.Shutdown(context.Background()) // Ensure shutdown
+			_ = g.Shutdown(t.Context()) // Ensure shutdown
 		}
 
 		out := testutil.StderrOutputForFunc(f)
@@ -85,7 +85,7 @@ func TestGRPC_ServerShutdown(t *testing.T) {
 	time.Sleep(10 * time.Millisecond)
 
 	// Create a context with a timeout to test the shutdown
-	ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
+	ctx, cancel := context.WithTimeout(t.Context(), 500*time.Millisecond)
 	defer cancel()
 
 	err := g.Shutdown(ctx)
@@ -105,7 +105,7 @@ func TestGRPC_ServerShutdown_ContextCanceled(t *testing.T) {
 	time.Sleep(10 * time.Millisecond)
 
 	// Create a context that can be canceled
-	ctx, cancel := context.WithCancel(context.Background())
+	ctx, cancel := context.WithCancel(t.Context())
 
 	errChan := make(chan error, 1)
 	go func() {
@@ -187,7 +187,7 @@ func TestGRPC_Shutdown_BeforeStart(t *testing.T) {
 
 	g := newGRPCServer(c, 9999)
 
-	ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
+	ctx, cancel := context.WithTimeout(t.Context(), 500*time.Millisecond)
 	defer cancel()
 
 	err := g.Shutdown(ctx)
@@ -233,7 +233,7 @@ func TestGRPC_ServerRun_WithInterceptorAndOptions(t *testing.T) {
 	go app.grpcServer.Run(&c)
 
 	defer func() {
-		_ = app.Shutdown(context.Background())
+		_ = app.Shutdown(t.Context())
 	}()
 
 	// Set the health status
@@ -248,7 +248,7 @@ func TestGRPC_ServerRun_WithInterceptorAndOptions(t *testing.T) {
 
 	// Test Health Check directly
 	healthClient := grpc_health_v1.NewHealthClient(conn)
-	healthResp, err := healthClient.Check(context.Background(), &grpc_health_v1.HealthCheckRequest{Service: "healthCheck"})
+	healthResp, err := healthClient.Check(t.Context(), &grpc_health_v1.HealthCheckRequest{Service: "healthCheck"})
 	require.NoError(t, err)
 	assert.Equal(t, grpc_health_v1.HealthCheckResponse_SERVING, healthResp.Status)
 
diff --git a/pkg/gofr/handler_test.go b/pkg/gofr/handler_test.go
index 69a7ff5d..d885952c 100644
--- a/pkg/gofr/handler_test.go
+++ b/pkg/gofr/handler_test.go
@@ -1,7 +1,6 @@
 package gofr
 
 import (
-	"context"
 	"errors"
 	"fmt"
 	"net/http"
@@ -166,7 +165,7 @@ func TestHandler_ServeHTTP_WithHeaders(t *testing.T) {
 
 func TestHandler_faviconHandlerError(t *testing.T) {
 	c := Context{
-		Context: context.Background(),
+		Context: t.Context(),
 	}
 
 	d, _ := os.ReadFile("static/favicon.ico")
@@ -202,7 +201,7 @@ func TestHandler_faviconHandlerError(t *testing.T) {
 
 func TestHandler_faviconHandler(t *testing.T) {
 	c := Context{
-		Context: context.Background(),
+		Context: t.Context(),
 	}
 
 	d, _ := os.ReadFile("static/favicon.ico")
@@ -218,7 +217,7 @@ func TestHandler_faviconHandler(t *testing.T) {
 
 func TestHandler_catchAllHandler(t *testing.T) {
 	c := Context{
-		Context: context.Background(),
+		Context: t.Context(),
 	}
 
 	data, err := catchAllHandler(&c)
@@ -248,7 +247,7 @@ func TestHandler_healthHandler(t *testing.T) {
 
 	a.AddHTTPService("test-service", server.URL)
 
-	req, _ := http.NewRequestWithContext(context.Background(), http.MethodGet, "", http.NoBody)
+	req, _ := http.NewRequestWithContext(t.Context(), http.MethodGet, "", http.NoBody)
 
 	r := gofrHTTP.NewRequest(req)
 
diff --git a/pkg/gofr/http/middleware/apikey_auth_test.go b/pkg/gofr/http/middleware/apikey_auth_test.go
index 7c92dee5..cb76c34e 100644
--- a/pkg/gofr/http/middleware/apikey_auth_test.go
+++ b/pkg/gofr/http/middleware/apikey_auth_test.go
@@ -1,7 +1,6 @@
 package middleware
 
 import (
-	"context"
 	"net/http"
 	"net/http/httptest"
 	"os"
@@ -34,7 +33,7 @@ func Test_ApiKeyAuthMiddleware(t *testing.T) {
 		return apiKey == validKey2
 	}
 
-	req, err := http.NewRequestWithContext(context.Background(), http.MethodGet, "/", http.NoBody)
+	req, err := http.NewRequestWithContext(t.Context(), http.MethodGet, "/", http.NoBody)
 	if err != nil {
 		t.Fatal(err)
 	}
diff --git a/pkg/gofr/http/middleware/logger_test.go b/pkg/gofr/http/middleware/logger_test.go
index d3056289..35d071d4 100644
--- a/pkg/gofr/http/middleware/logger_test.go
+++ b/pkg/gofr/http/middleware/logger_test.go
@@ -3,7 +3,6 @@ package middleware
 import (
 	"bufio"
 	"bytes"
-	"context"
 	"net"
 	"net/http"
 	"net/http/httptest"
@@ -21,7 +20,7 @@ func Test_getIPAddress(t *testing.T) {
 	{
 		// When RemoteAddr is set
 		addr := "0.0.0.0:8080"
-		req, err := http.NewRequestWithContext(context.Background(), http.MethodGet, "http://dummy", http.NoBody)
+		req, err := http.NewRequestWithContext(t.Context(), http.MethodGet, "http://dummy", http.NoBody)
 
 		require.NoError(t, err, "TEST Failed.\n")
 
@@ -34,7 +33,7 @@ func Test_getIPAddress(t *testing.T) {
 	{
 		// When `X-Forwarded-For` header is set
 		addr := "192.168.0.1:8080"
-		req, err := http.NewRequestWithContext(context.Background(), http.MethodGet, "http://dummy", http.NoBody)
+		req, err := http.NewRequestWithContext(t.Context(), http.MethodGet, "http://dummy", http.NoBody)
 
 		require.NoError(t, err, "TEST Failed.\n")
 
@@ -47,7 +46,7 @@ func Test_getIPAddress(t *testing.T) {
 
 func Test_LoggingMiddleware(t *testing.T) {
 	logs := testutil.StdoutOutputForFunc(func() {
-		req, _ := http.NewRequestWithContext(context.Background(), http.MethodGet, "http://dummy", http.NoBody)
+		req, _ := http.NewRequestWithContext(t.Context(), http.MethodGet, "http://dummy", http.NoBody)
 
 		rr := httptest.NewRecorder()
 
@@ -61,7 +60,7 @@ func Test_LoggingMiddleware(t *testing.T) {
 
 func Test_LoggingMiddlewareError(t *testing.T) {
 	logs := testutil.StderrOutputForFunc(func() {
-		req, _ := http.NewRequestWithContext(context.Background(), http.MethodGet, "http://dummy", http.NoBody)
+		req, _ := http.NewRequestWithContext(t.Context(), http.MethodGet, "http://dummy", http.NoBody)
 
 		rr := httptest.NewRecorder()
 
@@ -87,7 +86,7 @@ func testHandlerError(w http.ResponseWriter, _ *http.Request) {
 
 func Test_LoggingMiddlewareStringPanicHandling(t *testing.T) {
 	logs := testutil.StderrOutputForFunc(func() {
-		req, _ := http.NewRequestWithContext(context.Background(), http.MethodGet, "http://dummy", http.NoBody)
+		req, _ := http.NewRequestWithContext(t.Context(), http.MethodGet, "http://dummy", http.NoBody)
 
 		rr := httptest.NewRecorder()
 
@@ -106,7 +105,7 @@ func testStringPanicHandler(_ http.ResponseWriter, r *http.Request) {
 
 func Test_LoggingMiddlewareErrorPanicHandling(t *testing.T) {
 	logs := testutil.StderrOutputForFunc(func() {
-		req, _ := http.NewRequestWithContext(context.Background(), http.MethodGet, "http://dummy", http.NoBody)
+		req, _ := http.NewRequestWithContext(t.Context(), http.MethodGet, "http://dummy", http.NoBody)
 
 		rr := httptest.NewRecorder()
 
@@ -125,7 +124,7 @@ func testErrorPanicHandler(http.ResponseWriter, *http.Request) {
 
 func Test_LoggingMiddlewareUnknownPanicHandling(t *testing.T) {
 	logs := testutil.StderrOutputForFunc(func() {
-		req, _ := http.NewRequestWithContext(context.Background(), http.MethodGet, "http://dummy", http.NoBody)
+		req, _ := http.NewRequestWithContext(t.Context(), http.MethodGet, "http://dummy", http.NoBody)
 
 		rr := httptest.NewRecorder()
 
diff --git a/pkg/gofr/http/middleware/oauth_test.go b/pkg/gofr/http/middleware/oauth_test.go
index 916893f3..1a81cb3f 100644
--- a/pkg/gofr/http/middleware/oauth_test.go
+++ b/pkg/gofr/http/middleware/oauth_test.go
@@ -84,7 +84,7 @@ func TestOAuthInvalidTokenFormat(t *testing.T) {
 
 	server := httptest.NewServer(router)
 
-	req, _ := http.NewRequestWithContext(context.Background(), http.MethodGet, server.URL+"/test", http.NoBody)
+	req, _ := http.NewRequestWithContext(t.Context(), http.MethodGet, server.URL+"/test", http.NoBody)
 	req.Header.Set("Authorization", "eyJhb")
 
 	client := http.Client{}
@@ -109,7 +109,7 @@ func TestOAuthEmptyAuthHeader(t *testing.T) {
 
 	server := httptest.NewServer(router)
 
-	req, _ := http.NewRequestWithContext(context.Background(), http.MethodGet, server.URL+"/test", http.NoBody)
+	req, _ := http.NewRequestWithContext(t.Context(), http.MethodGet, server.URL+"/test", http.NoBody)
 
 	client := http.Client{}
 
@@ -133,7 +133,7 @@ func TestOAuthMalformedToken(t *testing.T) {
 
 	server := httptest.NewServer(router)
 
-	req, _ := http.NewRequestWithContext(context.Background(), http.MethodGet, server.URL+"/test", http.NoBody)
+	req, _ := http.NewRequestWithContext(t.Context(), http.MethodGet, server.URL+"/test", http.NoBody)
 	req.Header.Set("Authorization", "Bearer eyJh")
 
 	client := http.Client{}
@@ -158,7 +158,7 @@ func TestOAuthJWKSKeyNotFound(t *testing.T) {
 
 	server := httptest.NewServer(router)
 
-	req, _ := http.NewRequestWithContext(context.Background(), http.MethodGet, server.URL+"/test", http.NoBody)
+	req, _ := http.NewRequestWithContext(t.Context(), http.MethodGet, server.URL+"/test", http.NoBody)
 	req.Header.Set("Authorization", "Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6IjhaOV9RQTBSa0Y3RHM3TUFNaDFxLTl6dVJZ"+
 		"TklSTThHV3BZdXdyb0ZkTjg9IiwidHlwIjoiSldUIn0.eyJhdWQiOiJzdGFnZS5hdXRoLnpvcHNtYXJ0LmNvbSIsImV4cCI6MTcxODc5MDQ2My"+
 		"wiaWF0IjoxNzEwMTUwNDYzLCJpc3MiOiJzdGFnZS5hdXRoLnpvcHNtYXJ0LmNvbSIsIm5hbWUiOiJSYWtzaGl0IFNpbmdoIiwib3JpZyI6IkdP"+
@@ -421,7 +421,7 @@ func Test_OAuthSuccessWithValidation(t *testing.T) {
 func getRequest(t *testing.T, url string) *http.Request {
 	t.Helper()
 
-	req, _ := http.NewRequestWithContext(context.Background(), http.MethodGet, url+"/test", http.NoBody)
+	req, _ := http.NewRequestWithContext(t.Context(), http.MethodGet, url+"/test", http.NoBody)
 	req.Header.Set("Authorization", "Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6IjAwVFEwdlRpNVB1UnZscUZGY3dCeUc0WjBM"+
 		"dGREcUtJX0JWUFRrdnpleEUiLCJ0eXAiOiJKV1QifQ.eyJhdWQiOiJzdGFnZS5rb3BzLmRldiIsImlhdCI6MTI1Nzg5NDAwMCwib3JpZyI6IkdP"+
 		"T0dMRSIsInBpY3R1cmUiOiJodHRwczovL2xoMy5nb29nbGV1c2VyY29udGVudC5jb20vYS9BQ2c4b2NLSjVEREE0enJ1ekZsc1E5S3ZMakhEdG"+
diff --git a/pkg/gofr/http/request_test.go b/pkg/gofr/http/request_test.go
index a4554455..4a1a930b 100644
--- a/pkg/gofr/http/request_test.go
+++ b/pkg/gofr/http/request_test.go
@@ -2,7 +2,6 @@ package http
 
 import (
 	"bytes"
-	"context"
 	"errors"
 	"io"
 	"mime/multipart"
@@ -144,10 +143,10 @@ func TestBind_NoContentType(t *testing.T) {
 }
 
 func Test_GetContext(t *testing.T) {
-	req, _ := http.NewRequestWithContext(context.Background(), http.MethodGet, "test/hello", http.NoBody)
+	req, _ := http.NewRequestWithContext(t.Context(), http.MethodGet, "test/hello", http.NoBody)
 	r := Request{req: req, pathParams: map[string]string{"key": "hello"}}
 
-	assert.Equal(t, context.Background(), r.Context())
+	assert.Equal(t, t.Context(), r.Context())
 	assert.Equal(t, "http://", r.HostName())
 	assert.Equal(t, "hello", r.PathParam("key"))
 }
diff --git a/pkg/gofr/http_server_test.go b/pkg/gofr/http_server_test.go
index 236b044d..54d4b3f7 100644
--- a/pkg/gofr/http_server_test.go
+++ b/pkg/gofr/http_server_test.go
@@ -64,7 +64,7 @@ func TestRun_ServerStartsListening(t *testing.T) {
 	}
 
 	// Send a GET request to the server
-	req, _ := http.NewRequestWithContext(context.Background(), http.MethodGet,
+	req, _ := http.NewRequestWithContext(t.Context(), http.MethodGet,
 		fmt.Sprintf("http://localhost:%d", port), http.NoBody)
 	resp, err := netClient.Do(req)
 
@@ -109,7 +109,7 @@ func TestShutdown_ServerStopsListening(t *testing.T) {
 	go server.run(c)
 
 	// Create a context with a timeout to test the shutdown
-	ctx, cancel := context.WithTimeout(context.Background(), 150*time.Millisecond)
+	ctx, cancel := context.WithTimeout(t.Context(), 150*time.Millisecond)
 	defer cancel()
 
 	errChan := make(chan error, 1)
@@ -145,7 +145,7 @@ func TestShutdown_ServerContextDeadline(t *testing.T) {
 	go server.run(c)
 
 	// Create a context with a timeout to test the shutdown
-	ctx, cancel := context.WithTimeout(context.Background(), 50*time.Millisecond)
+	ctx, cancel := context.WithTimeout(t.Context(), 50*time.Millisecond)
 	defer cancel()
 
 	// Simulate a delay in the shutdown process to trigger context timeout
@@ -207,7 +207,7 @@ func TestValidateCertificateAndKeyFiles_Error(t *testing.T) {
 func createTempKeyFile(t *testing.T) string {
 	t.Helper()
 
-	f, err := os.CreateTemp("", "key-*.pem")
+	f, err := os.CreateTemp(t.TempDir(), "key-*.pem")
 	if err != nil {
 		t.Fatalf("could not create temp key file: %v", err)
 	}
@@ -221,7 +221,7 @@ func createTempKeyFile(t *testing.T) string {
 func createTempCertFile(t *testing.T) string {
 	t.Helper()
 
-	f, err := os.CreateTemp("", "cert-*.pem")
+	f, err := os.CreateTemp(t.TempDir(), "cert-*.pem")
 	if err != nil {
 		t.Fatalf("could not create temp cert file: %v", err)
 	}
diff --git a/pkg/gofr/metrics/handler_test.go b/pkg/gofr/metrics/handler_test.go
index 5d236d5e..8090e193 100644
--- a/pkg/gofr/metrics/handler_test.go
+++ b/pkg/gofr/metrics/handler_test.go
@@ -1,7 +1,6 @@
 package metrics
 
 import (
-	"context"
 	"io"
 	"net/http"
 	"net/http/httptest"
@@ -32,7 +31,7 @@ func Test_MetricsGetHandler_MetricsNotRegistered(t *testing.T) {
 
 		server = httptest.NewServer(handler)
 
-		req, _ := http.NewRequestWithContext(context.Background(), http.MethodGet, server.URL+"/metrics", http.NoBody)
+		req, _ := http.NewRequestWithContext(t.Context(), http.MethodGet, server.URL+"/metrics", http.NoBody)
 
 		resp, _ := server.Client().Do(req)
 		if resp != nil {
@@ -60,7 +59,7 @@ func Test_MetricsGetHandler_SystemMetricsRegistered(t *testing.T) {
 
 	server := httptest.NewServer(handler)
 
-	req, _ := http.NewRequestWithContext(context.Background(), http.MethodGet, server.URL+"/metrics", http.NoBody)
+	req, _ := http.NewRequestWithContext(t.Context(), http.MethodGet, server.URL+"/metrics", http.NoBody)
 
 	resp, err := server.Client().Do(req)
 
@@ -101,7 +100,7 @@ func Test_MetricsGetHandler_RegisteredProfilingRoutes(t *testing.T) {
 	}
 
 	for _, route := range expectedRoutes {
-		req, _ := http.NewRequestWithContext(context.Background(), http.MethodGet, server.URL+route, http.NoBody)
+		req, _ := http.NewRequestWithContext(t.Context(), http.MethodGet, server.URL+route, http.NoBody)
 		resp, err := server.Client().Do(req)
 
 		require.NotNil(t, resp)
diff --git a/pkg/gofr/metrics/register_test.go b/pkg/gofr/metrics/register_test.go
index d940a74a..83249e93 100644
--- a/pkg/gofr/metrics/register_test.go
+++ b/pkg/gofr/metrics/register_test.go
@@ -1,7 +1,6 @@
 package metrics
 
 import (
-	"context"
 	"io"
 	"net/http"
 	"net/http/httptest"
@@ -24,13 +23,13 @@ func Test_NewMetricsManagerSuccess(t *testing.T) {
 	metrics.NewHistogram("histogram-test", "this is metric to test histogram")
 
 	metrics.SetGauge("gauge-test", 50)
-	metrics.IncrementCounter(context.Background(), "counter-test")
-	metrics.DeltaUpDownCounter(context.Background(), "up-down-counter", 10)
-	metrics.RecordHistogram(context.Background(), "histogram-test", 1)
+	metrics.IncrementCounter(t.Context(), "counter-test")
+	metrics.DeltaUpDownCounter(t.Context(), "up-down-counter", 10)
+	metrics.RecordHistogram(t.Context(), "histogram-test", 1)
 
 	server := httptest.NewServer(GetHandler(metrics))
 
-	req, _ := http.NewRequestWithContext(context.Background(), http.MethodGet, server.URL+"/metrics", http.NoBody)
+	req, _ := http.NewRequestWithContext(t.Context(), http.MethodGet, server.URL+"/metrics", http.NoBody)
 
 	resp, _ := server.Client().Do(req)
 
@@ -72,9 +71,9 @@ func Test_NewMetricsManagerMetricsNotRegistered(t *testing.T) {
 			logging.NewMockLogger(logging.INFO))
 
 		metrics.SetGauge("gauge-test", 50)
-		metrics.IncrementCounter(context.Background(), "counter-test")
-		metrics.DeltaUpDownCounter(context.Background(), "up-down-counter", 10)
-		metrics.RecordHistogram(context.Background(), "histogram-test", 1)
+		metrics.IncrementCounter(t.Context(), "counter-test")
+		metrics.DeltaUpDownCounter(t.Context(), "up-down-counter", 10)
+		metrics.RecordHistogram(t.Context(), "histogram-test", 1)
 	}
 
 	log := testutil.StderrOutputForFunc(logs)
@@ -135,7 +134,7 @@ func Test_NewMetricsManagerInvalidLabelPairErrors(t *testing.T) {
 
 		metrics.NewCounter("counter-test", "this is metric to test counter")
 
-		metrics.IncrementCounter(context.Background(), "counter-test",
+		metrics.IncrementCounter(t.Context(), "counter-test",
 			"label1", "value1", "label2", "value2", "label3")
 	}
 
@@ -151,7 +150,7 @@ func Test_NewMetricsManagerLabelHighCardinality(t *testing.T) {
 
 		metrics.NewCounter("counter-test", "this is metric to test counter")
 
-		metrics.IncrementCounter(context.Background(), "counter-test",
+		metrics.IncrementCounter(t.Context(), "counter-test",
 			"label1", "value1", "label2", "value2", "label3", "value3", "label4", "value4", "label5", "value5", "label6", "value6",
 			"label7", "value7", "label8", "value8", "label9", "value9", "label10", "value10", "label11", "value11", "label12", "value12")
 	}
diff --git a/pkg/gofr/migration/arango_test.go b/pkg/gofr/migration/arango_test.go
index 6fd5f01e..eee74c65 100644
--- a/pkg/gofr/migration/arango_test.go
+++ b/pkg/gofr/migration/arango_test.go
@@ -47,7 +47,7 @@ func Test_ArangoCheckAndCreateMigrationTable(t *testing.T) {
 	}
 
 	for i, tc := range testCases {
-		mockArango.EXPECT().CreateCollection(context.Background(), arangoMigrationDB, arangoMigrationCollection, false).Return(tc.err)
+		mockArango.EXPECT().CreateCollection(t.Context(), arangoMigrationDB, arangoMigrationCollection, false).Return(tc.err)
 
 		err := migratorWithArango.checkAndCreateMigrationTable(mockContainer)
 
@@ -70,7 +70,7 @@ func Test_ArangoGetLastMigration(t *testing.T) {
 	var lastMigrations []int64
 
 	for i, tc := range testCases {
-		mockArango.EXPECT().Query(context.Background(), arangoMigrationDB, getLastArangoMigration, nil, &lastMigrations).Return(tc.err)
+		mockArango.EXPECT().Query(t.Context(), arangoMigrationDB, getLastArangoMigration, nil, &lastMigrations).Return(tc.err)
 
 		resp := migratorWithArango.getLastMigration(mockContainer)
 
@@ -104,7 +104,7 @@ func Test_ArangoCommitMigration(t *testing.T) {
 			"duration":   time.Since(td.StartTime).Milliseconds(),
 		}
 
-		mockArango.EXPECT().Query(context.Background(), arangoMigrationDB, insertArangoMigrationRecord, bindVars, gomock.Any()).Return(tc.err)
+		mockArango.EXPECT().Query(t.Context(), arangoMigrationDB, insertArangoMigrationRecord, bindVars, gomock.Any()).Return(tc.err)
 
 		err := migratorWithArango.commitMigration(mockContainer, td)
 
diff --git a/pkg/gofr/migration/cassandra_test.go b/pkg/gofr/migration/cassandra_test.go
index 97aff149..e959b32d 100644
--- a/pkg/gofr/migration/cassandra_test.go
+++ b/pkg/gofr/migration/cassandra_test.go
@@ -1,7 +1,6 @@
 package migration
 
 import (
-	"context"
 	"database/sql"
 	"testing"
 	"time"
@@ -42,7 +41,7 @@ func Test_CassandraCheckAndCreateMigrationTable(t *testing.T) {
 	}
 
 	for i, tc := range testCases {
-		mockCassandra.EXPECT().ExecWithCtx(context.Background(), checkAndCreateCassandraMigrationTable).Return(tc.err)
+		mockCassandra.EXPECT().ExecWithCtx(t.Context(), checkAndCreateCassandraMigrationTable).Return(tc.err)
 
 		err := migratorWithCassandra.checkAndCreateMigrationTable(mockContainer)
 
@@ -65,7 +64,7 @@ func Test_CassandraGetLastMigration(t *testing.T) {
 	var lastMigration []int64
 
 	for i, tc := range testCases {
-		mockCassandra.EXPECT().QueryWithCtx(context.Background(), &lastMigration, getLastCassandraGoFrMigration).Return(tc.err)
+		mockCassandra.EXPECT().QueryWithCtx(t.Context(), &lastMigration, getLastCassandraGoFrMigration).Return(tc.err)
 
 		resp := migratorWithCassandra.getLastMigration(mockContainer)
 
@@ -92,7 +91,7 @@ func Test_CassandraCommitMigration(t *testing.T) {
 	}
 
 	for i, tc := range testCases {
-		mockCassandra.EXPECT().ExecWithCtx(context.Background(), insertCassandraGoFrMigrationRow, td.MigrationNumber,
+		mockCassandra.EXPECT().ExecWithCtx(t.Context(), insertCassandraGoFrMigrationRow, td.MigrationNumber,
 			"UP", td.StartTime, gomock.Any()).Return(tc.err)
 
 		err := migratorWithCassandra.commitMigration(mockContainer, td)
diff --git a/pkg/gofr/migration/dgraph_test.go b/pkg/gofr/migration/dgraph_test.go
index 9423a2d2..18b6871d 100644
--- a/pkg/gofr/migration/dgraph_test.go
+++ b/pkg/gofr/migration/dgraph_test.go
@@ -32,7 +32,7 @@ func dgraphSetup(t *testing.T) (migrator, *container.MockDgraph, *container.Cont
 func Test_DGraphCheckAndCreateMigrationTable(t *testing.T) {
 	migratorWithDGraph, mockDGraph, mockContainer := dgraphSetup(t)
 
-	mockDGraph.EXPECT().ApplySchema(context.Background(), dgraphSchema).Return(nil)
+	mockDGraph.EXPECT().ApplySchema(t.Context(), dgraphSchema).Return(nil)
 
 	err := migratorWithDGraph.checkAndCreateMigrationTable(mockContainer)
 
@@ -77,7 +77,7 @@ func Test_DGraphGetLastMigration(t *testing.T) {
 	for i, tc := range testCases {
 		t.Run(tc.desc, func(t *testing.T) {
 			// Set up mock expectation for the main query
-			mockDGraph.EXPECT().Query(context.Background(), getLastMigrationQuery).
+			mockDGraph.EXPECT().Query(t.Context(), getLastMigrationQuery).
 				Return(tc.mockResp, tc.err)
 
 			resp := migratorWithDGraph.getLastMigration(mockContainer)
@@ -106,7 +106,7 @@ func Test_DGraphCommitMigration(t *testing.T) {
 	}
 
 	for i, tc := range testCases {
-		mockDGraph.EXPECT().Mutate(context.Background(), gomock.Any()).Return(nil, tc.err)
+		mockDGraph.EXPECT().Mutate(t.Context(), gomock.Any()).Return(nil, tc.err)
 
 		err := migratorWithDGraph.commitMigration(mockContainer, td)
 
@@ -127,7 +127,7 @@ func Test_DGraphDS_ApplySchema(t *testing.T) {
 	_, mockDGraph, _ := dgraphSetup(t)
 
 	ds := dgraphDS{client: mockDGraph}
-	ctx := context.Background()
+	ctx := t.Context()
 	schema := "test schema"
 
 	testCases := []struct {
@@ -151,7 +151,7 @@ func Test_DGraphDS_AddOrUpdateField(t *testing.T) {
 	_, mockDGraph, _ := dgraphSetup(t)
 
 	ds := dgraphDS{client: mockDGraph}
-	ctx := context.Background()
+	ctx := t.Context()
 	fieldName := "test"
 	fieldType := "string"
 	directives := "@index(exact)"
@@ -177,7 +177,7 @@ func Test_DGraphDS_DropField(t *testing.T) {
 	_, mockDGraph, _ := dgraphSetup(t)
 
 	ds := dgraphDS{client: mockDGraph}
-	ctx := context.Background()
+	ctx := t.Context()
 	fieldName := "test"
 
 	testCases := []struct {
diff --git a/pkg/gofr/migration/migration_test.go b/pkg/gofr/migration/migration_test.go
index 6ed1063f..2530afcb 100644
--- a/pkg/gofr/migration/migration_test.go
+++ b/pkg/gofr/migration/migration_test.go
@@ -1,7 +1,6 @@
 package migration
 
 import (
-	"context"
 	"database/sql"
 	"testing"
 
@@ -79,7 +78,7 @@ func TestMigrationRunClickhouseSuccess(t *testing.T) {
 	logs := testutil.StdoutOutputForFunc(func() {
 		migrationMap := map[int64]Migrate{
 			1: {UP: func(d Datasource) error {
-				err := d.Clickhouse.Exec(context.Background(), "SELECT * FROM users")
+				err := d.Clickhouse.Exec(t.Context(), "SELECT * FROM users")
 				if err != nil {
 					return err
 				}
@@ -111,7 +110,7 @@ func TestMigrationRunClickhouseMigrationFailure(t *testing.T) {
 
 		migrationMap := map[int64]Migrate{
 			1: {UP: func(d Datasource) error {
-				err := d.Clickhouse.Exec(context.Background(), "SELECT * FROM users")
+				err := d.Clickhouse.Exec(t.Context(), "SELECT * FROM users")
 				if err != nil {
 					return err
 				}
@@ -138,7 +137,7 @@ func TestMigrationRunClickhouseMigrationFailureWhileCheckingTable(t *testing.T)
 	testutil.StderrOutputForFunc(func() {
 		migrationMap := map[int64]Migrate{
 			1: {UP: func(d Datasource) error {
-				err := d.Clickhouse.Exec(context.Background(), "SELECT * FROM users")
+				err := d.Clickhouse.Exec(t.Context(), "SELECT * FROM users")
 				if err != nil {
 					return err
 				}
@@ -159,7 +158,7 @@ func TestMigrationRunClickhouseCurrentMigrationEqualLastMigration(t *testing.T)
 	logs := testutil.StdoutOutputForFunc(func() {
 		migrationMap := map[int64]Migrate{
 			0: {UP: func(d Datasource) error {
-				err := d.Clickhouse.Exec(context.Background(), "SELECT * FROM users")
+				err := d.Clickhouse.Exec(t.Context(), "SELECT * FROM users")
 				if err != nil {
 					return err
 				}
@@ -183,7 +182,7 @@ func TestMigrationRunClickhouseCommitError(t *testing.T) {
 	logs := testutil.StderrOutputForFunc(func() {
 		migrationMap := map[int64]Migrate{
 			1: {UP: func(d Datasource) error {
-				err := d.Clickhouse.Exec(context.Background(), "SELECT * FROM users")
+				err := d.Clickhouse.Exec(t.Context(), "SELECT * FROM users")
 				if err != nil {
 					return err
 				}
diff --git a/pkg/gofr/migration/mongo_test.go b/pkg/gofr/migration/mongo_test.go
index 9de31a05..14ab07f1 100644
--- a/pkg/gofr/migration/mongo_test.go
+++ b/pkg/gofr/migration/mongo_test.go
@@ -1,7 +1,6 @@
 package migration
 
 import (
-	"context"
 	"errors"
 	"testing"
 	"time"
@@ -42,7 +41,7 @@ func Test_MongoCheckAndCreateMigrationTable(t *testing.T) {
 	}
 
 	for i, tc := range testCases {
-		mockMongo.EXPECT().CreateCollection(context.Background(), mongoMigrationCollection).Return(tc.err)
+		mockMongo.EXPECT().CreateCollection(t.Context(), mongoMigrationCollection).Return(tc.err)
 		err := migratorWithMongo.checkAndCreateMigrationTable(mockContainer)
 
 		assert.Equal(t, tc.err, err, "TEST[%v]\n %v Failed! ", i, tc.desc)
@@ -68,7 +67,7 @@ func Test_MongoGetLastMigration(t *testing.T) {
 	filter := make(map[string]any)
 
 	for i, tc := range testCases {
-		mockMongo.EXPECT().Find(context.Background(), mongoMigrationCollection, filter, &migrations).Return(tc.err)
+		mockMongo.EXPECT().Find(t.Context(), mongoMigrationCollection, filter, &migrations).Return(tc.err)
 
 		resp := migratorWithMongo.getLastMigration(mockContainer)
 
@@ -106,7 +105,7 @@ func Test_MongoCommitMigration(t *testing.T) {
 	}
 
 	for i, tc := range testCases {
-		mockMongo.EXPECT().InsertOne(context.Background(), mongoMigrationCollection, migrationDoc).Return(mockResult, tc.err)
+		mockMongo.EXPECT().InsertOne(t.Context(), mongoMigrationCollection, migrationDoc).Return(mockResult, tc.err)
 
 		err := migratorWithMongo.commitMigration(mockContainer, td)
 
diff --git a/pkg/gofr/migration/redis_test.go b/pkg/gofr/migration/redis_test.go
index e94fb840..164a177a 100644
--- a/pkg/gofr/migration/redis_test.go
+++ b/pkg/gofr/migration/redis_test.go
@@ -1,7 +1,6 @@
 package migration
 
 import (
-	"context"
 	"testing"
 	"time"
 
@@ -18,10 +17,10 @@ func TestRedis_Get(t *testing.T) {
 	defer ctrl.Finish()
 
 	mockCmd := NewMockRedis(ctrl)
-	mockCmd.EXPECT().Get(context.Background(), "test_key").Return(&goRedis.StringCmd{})
+	mockCmd.EXPECT().Get(t.Context(), "test_key").Return(&goRedis.StringCmd{})
 
 	r := redisDS{mockCmd}
-	_, err := r.Get(context.Background(), "test_key").Result()
+	_, err := r.Get(t.Context(), "test_key").Result()
 
 	require.NoError(t, err, "TEST Failed.\n")
 }
@@ -31,10 +30,10 @@ func TestRedis_Set(t *testing.T) {
 	defer ctrl.Finish()
 
 	mockCmd := NewMockRedis(ctrl)
-	mockCmd.EXPECT().Set(context.Background(), "test_key", "test_value", time.Duration(0)).Return(&goRedis.StatusCmd{})
+	mockCmd.EXPECT().Set(t.Context(), "test_key", "test_value", time.Duration(0)).Return(&goRedis.StatusCmd{})
 
 	r := redisDS{mockCmd}
-	_, err := r.Set(context.Background(), "test_key", "test_value", 0).Result()
+	_, err := r.Set(t.Context(), "test_key", "test_value", 0).Result()
 
 	require.NoError(t, err, "TEST Failed.\n")
 }
@@ -44,10 +43,10 @@ func TestRedis_Del(t *testing.T) {
 	defer ctrl.Finish()
 
 	mockCmd := NewMockRedis(ctrl)
-	mockCmd.EXPECT().Del(context.Background(), "test_key").Return(&goRedis.IntCmd{})
+	mockCmd.EXPECT().Del(t.Context(), "test_key").Return(&goRedis.IntCmd{})
 
 	r := redisDS{mockCmd}
-	_, err := r.Del(context.Background(), "test_key").Result()
+	_, err := r.Del(t.Context(), "test_key").Result()
 
 	require.NoError(t, err, "TEST Failed.\n")
 }
@@ -57,10 +56,10 @@ func TestRedis_Rename(t *testing.T) {
 	defer ctrl.Finish()
 
 	mockCmd := NewMockRedis(ctrl)
-	mockCmd.EXPECT().Rename(context.Background(), "test_key", "test_new_key").Return(&goRedis.StatusCmd{})
+	mockCmd.EXPECT().Rename(t.Context(), "test_key", "test_new_key").Return(&goRedis.StatusCmd{})
 
 	r := redisDS{mockCmd}
-	_, err := r.Rename(context.Background(), "test_key", "test_new_key").Result()
+	_, err := r.Rename(t.Context(), "test_key", "test_new_key").Result()
 
 	require.NoError(t, err, "TEST Failed.\n")
 }
@@ -119,7 +118,7 @@ func TestRedisMigrator_GetLastMigration(t *testing.T) {
 	}
 
 	for i, tc := range tests {
-		mocks.Redis.EXPECT().HGetAll(context.Background(), "gofr_migrations").Return(
+		mocks.Redis.EXPECT().HGetAll(t.Context(), "gofr_migrations").Return(
 			goRedis.NewMapStringStringResult(tc.mockedData, tc.redisErr))
 
 		mockMigrator.EXPECT().getLastMigration(gomock.Any()).Return(tc.migratorLastMigration).MaxTimes(2)
diff --git a/pkg/gofr/migration/sql_test.go b/pkg/gofr/migration/sql_test.go
index c1bfb179..3459d5f0 100644
--- a/pkg/gofr/migration/sql_test.go
+++ b/pkg/gofr/migration/sql_test.go
@@ -1,7 +1,6 @@
 package migration
 
 import (
-	"context"
 	"database/sql"
 	"errors"
 	"testing"
@@ -95,7 +94,7 @@ func TestQueryRow(t *testing.T) {
 }
 
 func TestQueryRowContext(t *testing.T) {
-	ctx := context.Background()
+	ctx := t.Context()
 
 	t.Run("successful query row context", func(t *testing.T) {
 		var id int
@@ -158,7 +157,7 @@ func TestExec(t *testing.T) {
 }
 
 func TestExecContext(t *testing.T) {
-	ctx := context.Background()
+	ctx := t.Context()
 
 	t.Run("successful exec context", func(t *testing.T) {
 		mockContainer, mocks := container.NewMockContainer(t)
diff --git a/pkg/gofr/migration/surreal_db_test.go b/pkg/gofr/migration/surreal_db_test.go
index 9b02f012..22b81bb0 100644
--- a/pkg/gofr/migration/surreal_db_test.go
+++ b/pkg/gofr/migration/surreal_db_test.go
@@ -42,7 +42,7 @@ func Test_SurrealCheckAndCreateMigrationTable(t *testing.T) {
 	}
 
 	for i, tc := range testCases {
-		mockSurreal.EXPECT().Query(context.Background(), gomock.Any(), nil).Return([]any{}, tc.err).MaxTimes(8)
+		mockSurreal.EXPECT().Query(t.Context(), gomock.Any(), nil).Return([]any{}, tc.err).MaxTimes(8)
 
 		err := migratorWithSurreal.checkAndCreateMigrationTable(mockContainer)
 
@@ -63,7 +63,7 @@ func Test_SurrealGetLastMigration(t *testing.T) {
 	}
 
 	for i, tc := range testCases {
-		mockSurreal.EXPECT().Query(context.Background(), getLastSurrealDBGoFrMigration, nil).Return([]any{
+		mockSurreal.EXPECT().Query(t.Context(), getLastSurrealDBGoFrMigration, nil).Return([]any{
 			map[string]any{"version": float64(tc.resp)},
 		}, tc.err)
 
@@ -99,7 +99,7 @@ func Test_SurrealCommitMigration(t *testing.T) {
 			"duration":   time.Since(td.StartTime).Milliseconds(),
 		}
 
-		mockSurreal.EXPECT().Query(context.Background(), insertSurrealDBGoFrMigrationRow, bindVars).Return([]any{}, tc.err)
+		mockSurreal.EXPECT().Query(t.Context(), insertSurrealDBGoFrMigrationRow, bindVars).Return([]any{}, tc.err)
 
 		err := migratorWithSurreal.commitMigration(mockContainer, td)
 
@@ -122,10 +122,10 @@ func TestSurrealDS_Query(t *testing.T) {
 	query := "SELECT * FROM table"
 	vars := map[string]any{"key": "value"}
 	expectedResult := []any{"result"}
-	mockSurreal.EXPECT().Query(context.Background(), query, vars).Return(expectedResult, nil)
+	mockSurreal.EXPECT().Query(t.Context(), query, vars).Return(expectedResult, nil)
 
 	surreal := surrealDS{client: mockSurreal}
-	result, err := surreal.Query(context.Background(), query, vars)
+	result, err := surreal.Query(t.Context(), query, vars)
 
 	require.NoError(t, err)
 	assert.Equal(t, expectedResult, result)
@@ -135,10 +135,10 @@ func TestSurrealDS_CreateNamespace(t *testing.T) {
 	_, mockSurreal, _ := surrealSetup(t)
 
 	namespace := "test_namespace"
-	mockSurreal.EXPECT().CreateNamespace(context.Background(), namespace).Return(nil)
+	mockSurreal.EXPECT().CreateNamespace(t.Context(), namespace).Return(nil)
 
 	surreal := surrealDS{client: mockSurreal}
-	err := surreal.CreateNamespace(context.Background(), namespace)
+	err := surreal.CreateNamespace(t.Context(), namespace)
 
 	assert.NoError(t, err)
 }
@@ -147,10 +147,10 @@ func TestSurrealDS_CreateDatabase(t *testing.T) {
 	_, mockSurreal, _ := surrealSetup(t)
 
 	database := "test_database"
-	mockSurreal.EXPECT().CreateDatabase(context.Background(), database).Return(nil)
+	mockSurreal.EXPECT().CreateDatabase(t.Context(), database).Return(nil)
 
 	surreal := surrealDS{client: mockSurreal}
-	err := surreal.CreateDatabase(context.Background(), database)
+	err := surreal.CreateDatabase(t.Context(), database)
 
 	assert.NoError(t, err)
 }
@@ -159,10 +159,10 @@ func TestSurrealDS_DropNamespace(t *testing.T) {
 	_, mockSurreal, _ := surrealSetup(t)
 
 	namespace := "test_namespace"
-	mockSurreal.EXPECT().DropNamespace(context.Background(), namespace).Return(nil)
+	mockSurreal.EXPECT().DropNamespace(t.Context(), namespace).Return(nil)
 
 	surreal := surrealDS{client: mockSurreal}
-	err := surreal.DropNamespace(context.Background(), namespace)
+	err := surreal.DropNamespace(t.Context(), namespace)
 
 	assert.NoError(t, err)
 }
@@ -171,10 +171,10 @@ func TestSurrealDS_DropDatabase(t *testing.T) {
 	_, mockSurreal, _ := surrealSetup(t)
 
 	database := "test_database"
-	mockSurreal.EXPECT().DropDatabase(context.Background(), database).Return(nil)
+	mockSurreal.EXPECT().DropDatabase(t.Context(), database).Return(nil)
 
 	surreal := surrealDS{client: mockSurreal}
-	err := surreal.DropDatabase(context.Background(), database)
+	err := surreal.DropDatabase(t.Context(), database)
 
 	assert.NoError(t, err)
 }
diff --git a/pkg/gofr/service/apikey_auth_test.go b/pkg/gofr/service/apikey_auth_test.go
index af9c7bbb..5c2260e9 100644
--- a/pkg/gofr/service/apikey_auth_test.go
+++ b/pkg/gofr/service/apikey_auth_test.go
@@ -1,7 +1,6 @@
 package service
 
 import (
-	"context"
 	"io"
 	"net/http"
 	"net/http/httptest"
@@ -43,7 +42,7 @@ func Test_APIKeyAuthProvider_Get(t *testing.T) {
 	httpService := NewHTTPService(server.URL, logging.NewMockLogger(logging.INFO), nil,
 		&APIKeyConfig{"valid-key"})
 
-	resp, err := httpService.Get(context.Background(), path, queryParams)
+	resp, err := httpService.Get(t.Context(), path, queryParams)
 	require.NoError(t, err)
 
 	defer resp.Body.Close()
@@ -74,7 +73,7 @@ func Test_APIKeyAuthProvider_Post(t *testing.T) {
 	httpService := NewHTTPService(server.URL, logging.NewMockLogger(logging.INFO), nil,
 		&APIKeyConfig{"valid-key"})
 
-	resp, err := httpService.Post(context.Background(), path, queryParams, body)
+	resp, err := httpService.Post(t.Context(), path, queryParams, body)
 	require.NoError(t, err)
 
 	defer resp.Body.Close()
@@ -101,7 +100,7 @@ func TestApiKeyProvider_Put(t *testing.T) {
 	httpService := NewHTTPService(server.URL, logging.NewMockLogger(logging.INFO), nil,
 		&APIKeyConfig{"valid-key"})
 
-	resp, err := httpService.Put(context.Background(), path, queryParams, body)
+	resp, err := httpService.Put(t.Context(), path, queryParams, body)
 	require.NoError(t, err)
 
 	defer resp.Body.Close()
@@ -128,7 +127,7 @@ func TestApiKeyAuthProvider_Patch(t *testing.T) {
 	httpService := NewHTTPService(server.URL, logging.NewMockLogger(logging.INFO), nil,
 		&APIKeyConfig{"valid-key"})
 
-	resp, err := httpService.Patch(context.Background(), path, queryParams, body)
+	resp, err := httpService.Patch(t.Context(), path, queryParams, body)
 	require.NoError(t, err)
 
 	defer resp.Body.Close()
@@ -154,7 +153,7 @@ func TestApiKeyAuthProvider_Delete(t *testing.T) {
 	httpService := NewHTTPService(server.URL, logging.NewMockLogger(logging.INFO), nil,
 		&APIKeyConfig{"valid-key"})
 
-	resp, err := httpService.Delete(context.Background(), path, body)
+	resp, err := httpService.Delete(t.Context(), path, body)
 	require.NoError(t, err)
 
 	defer resp.Body.Close()
diff --git a/pkg/gofr/service/basic_auth_test.go b/pkg/gofr/service/basic_auth_test.go
index 818a8752..1e17d188 100644
--- a/pkg/gofr/service/basic_auth_test.go
+++ b/pkg/gofr/service/basic_auth_test.go
@@ -1,7 +1,6 @@
 package service
 
 import (
-	"context"
 	"encoding/base64"
 	"io"
 	"net/http"
@@ -43,7 +42,7 @@ func TestBasicAuthProvider_Get(t *testing.T) {
 		&BasicAuthConfig{UserName: "user", Password: "cGFzc3dvcmQ="})
 
 	// Make the GET request
-	resp, err := httpService.Get(context.Background(), path, queryParams)
+	resp, err := httpService.Get(t.Context(), path, queryParams)
 	require.NoError(t, err)
 
 	defer resp.Body.Close()
@@ -79,7 +78,7 @@ func TestBasicAuthProvider_Post(t *testing.T) {
 		&BasicAuthConfig{UserName: "user", Password: "cGFzc3dvcmQ="})
 
 	// Make the POST request
-	resp, err := httpService.Post(context.Background(), path, queryParams, body)
+	resp, err := httpService.Post(t.Context(), path, queryParams, body)
 	require.NoError(t, err)
 
 	defer resp.Body.Close()
@@ -111,7 +110,7 @@ func TestBasicAuthProvider_Put(t *testing.T) {
 		&BasicAuthConfig{UserName: "user", Password: "cGFzc3dvcmQ="})
 
 	// Make the PUT request
-	resp, err := httpService.Put(context.Background(), path, queryParams, body)
+	resp, err := httpService.Put(t.Context(), path, queryParams, body)
 	require.NoError(t, err)
 
 	defer resp.Body.Close()
@@ -143,7 +142,7 @@ func TestBasicAuthProvider_Patch(t *testing.T) {
 		&BasicAuthConfig{UserName: "user", Password: "cGFzc3dvcmQ="})
 
 	// Make the PATCH request
-	resp, err := httpService.Patch(context.Background(), path, queryParams, body)
+	resp, err := httpService.Patch(t.Context(), path, queryParams, body)
 	require.NoError(t, err)
 
 	defer resp.Body.Close()
@@ -174,7 +173,7 @@ func TestBasicAuthProvider_Delete(t *testing.T) {
 		&BasicAuthConfig{UserName: "user", Password: "cGFzc3dvcmQ="})
 
 	// Make the DELETE request
-	resp, err := httpService.Delete(context.Background(), path, body)
+	resp, err := httpService.Delete(t.Context(), path, body)
 	require.NoError(t, err)
 
 	defer resp.Body.Close()
diff --git a/pkg/gofr/service/circuit_breaker_test.go b/pkg/gofr/service/circuit_breaker_test.go
index 88c63a33..dfb28685 100644
--- a/pkg/gofr/service/circuit_breaker_test.go
+++ b/pkg/gofr/service/circuit_breaker_test.go
@@ -68,7 +68,7 @@ func TestHttpService_GetSuccessRequests(t *testing.T) {
 		Interval:  1,
 	})
 
-	resp, err := service.Get(context.Background(), "test", nil)
+	resp, err := service.Get(t.Context(), "test", nil)
 
 	require.NoError(t, err)
 	assert.Equal(t, http.StatusOK, resp.StatusCode)
@@ -90,7 +90,7 @@ func TestHttpService_GetWithHeaderSuccessRequests(t *testing.T) {
 		Interval:  1,
 	})
 
-	resp, err := service.GetWithHeaders(context.Background(), "test", nil, nil)
+	resp, err := service.GetWithHeaders(t.Context(), "test", nil, nil)
 
 	require.NoError(t, err)
 	assert.Equal(t, http.StatusOK, resp.StatusCode)
@@ -116,7 +116,7 @@ func TestHttpService_GetCBOpenRequests(t *testing.T) {
 
 	// Perform test cases
 	for _, tc := range testCases {
-		resp, err := service.Get(context.Background(), tc.path, nil)
+		resp, err := service.Get(t.Context(), tc.path, nil)
 
 		if tc.expectErr {
 			require.Error(t, err)
@@ -147,7 +147,7 @@ func TestHttpService_GetWithHeaderCBOpenRequests(t *testing.T) {
 
 	// Perform test cases
 	for _, tc := range testCases {
-		resp, err := service.GetWithHeaders(context.Background(), tc.path, nil, nil)
+		resp, err := service.GetWithHeaders(t.Context(), tc.path, nil, nil)
 
 		if tc.expectErr {
 			require.Error(t, err)
@@ -174,7 +174,7 @@ func TestHttpService_PutSuccessRequests(t *testing.T) {
 		Interval:  1,
 	})
 
-	resp, err := service.Put(context.Background(), "test", nil, nil)
+	resp, err := service.Put(t.Context(), "test", nil, nil)
 
 	require.NoError(t, err)
 	assert.Equal(t, http.StatusOK, resp.StatusCode)
@@ -196,7 +196,7 @@ func TestHttpService_PutWithHeaderSuccessRequests(t *testing.T) {
 		Interval:  1,
 	})
 
-	resp, err := service.PutWithHeaders(context.Background(), "test", nil, nil, nil)
+	resp, err := service.PutWithHeaders(t.Context(), "test", nil, nil, nil)
 
 	require.NoError(t, err)
 	assert.Equal(t, http.StatusOK, resp.StatusCode)
@@ -222,7 +222,7 @@ func TestHttpService_PutCBOpenRequests(t *testing.T) {
 
 	// Perform test cases
 	for _, tc := range testCases {
-		resp, err := service.Put(context.Background(), tc.path, nil, nil)
+		resp, err := service.Put(t.Context(), tc.path, nil, nil)
 
 		if tc.expectErr {
 			require.Error(t, err)
@@ -253,7 +253,7 @@ func TestHttpService_PutWithHeaderCBOpenRequests(t *testing.T) {
 
 	// Perform test cases
 	for _, tc := range testCases {
-		resp, err := service.PutWithHeaders(context.Background(), tc.path, nil, nil, nil)
+		resp, err := service.PutWithHeaders(t.Context(), tc.path, nil, nil, nil)
 
 		if tc.expectErr {
 			require.Error(t, err)
@@ -280,7 +280,7 @@ func TestHttpService_PatchSuccessRequests(t *testing.T) {
 		Interval:  1,
 	})
 
-	resp, err := service.Get(context.Background(), "test", nil)
+	resp, err := service.Get(t.Context(), "test", nil)
 
 	require.NoError(t, err)
 	assert.Equal(t, http.StatusOK, resp.StatusCode)
@@ -302,7 +302,7 @@ func TestHttpService_PatchWithHeaderSuccessRequests(t *testing.T) {
 		Interval:  1,
 	})
 
-	resp, err := service.GetWithHeaders(context.Background(), "test", nil, nil)
+	resp, err := service.GetWithHeaders(t.Context(), "test", nil, nil)
 
 	require.NoError(t, err)
 	assert.Equal(t, http.StatusOK, resp.StatusCode)
@@ -328,7 +328,7 @@ func TestHttpService_PatchCBOpenRequests(t *testing.T) {
 
 	// Perform test cases
 	for _, tc := range testCases {
-		resp, err := service.Patch(context.Background(), tc.path, nil, nil)
+		resp, err := service.Patch(t.Context(), tc.path, nil, nil)
 
 		if tc.expectErr {
 			require.Error(t, err)
@@ -359,7 +359,7 @@ func TestHttpService_PatchWithHeaderCBOpenRequests(t *testing.T) {
 
 	// Perform test cases
 	for _, tc := range testCases {
-		resp, err := service.PatchWithHeaders(context.Background(), tc.path, nil, nil, nil)
+		resp, err := service.PatchWithHeaders(t.Context(), tc.path, nil, nil, nil)
 
 		if tc.expectErr {
 			require.Error(t, err)
@@ -386,7 +386,7 @@ func TestHttpService_PostSuccessRequests(t *testing.T) {
 		Interval:  1,
 	})
 
-	resp, err := service.Post(context.Background(), "test", nil, nil)
+	resp, err := service.Post(t.Context(), "test", nil, nil)
 
 	require.NoError(t, err)
 	assert.Equal(t, http.StatusOK, resp.StatusCode)
@@ -408,7 +408,7 @@ func TestHttpService_PostWithHeaderSuccessRequests(t *testing.T) {
 		Interval:  1,
 	})
 
-	resp, err := service.PostWithHeaders(context.Background(), "test", nil, nil, nil)
+	resp, err := service.PostWithHeaders(t.Context(), "test", nil, nil, nil)
 
 	require.NoError(t, err)
 	assert.Equal(t, http.StatusOK, resp.StatusCode)
@@ -434,7 +434,7 @@ func TestHttpService_PostCBOpenRequests(t *testing.T) {
 
 	// Perform test cases
 	for _, tc := range testCases {
-		resp, err := service.Post(context.Background(), tc.path, nil, nil)
+		resp, err := service.Post(t.Context(), tc.path, nil, nil)
 
 		if tc.expectErr {
 			require.Error(t, err)
@@ -465,7 +465,7 @@ func TestHttpService_PostWithHeaderCBOpenRequests(t *testing.T) {
 
 	// Perform test cases
 	for _, tc := range testCases {
-		resp, err := service.PostWithHeaders(context.Background(), tc.path, nil, nil, nil)
+		resp, err := service.PostWithHeaders(t.Context(), tc.path, nil, nil, nil)
 
 		if tc.expectErr {
 			require.Error(t, err)
@@ -492,7 +492,7 @@ func TestHttpService_DeleteSuccessRequests(t *testing.T) {
 		Interval:  1,
 	})
 
-	resp, err := service.Delete(context.Background(), "test", nil)
+	resp, err := service.Delete(t.Context(), "test", nil)
 
 	require.NoError(t, err)
 	assert.Equal(t, http.StatusOK, resp.StatusCode)
@@ -514,7 +514,7 @@ func TestHttpService_DeleteWithHeaderSuccessRequests(t *testing.T) {
 		Interval:  1,
 	})
 
-	resp, err := service.DeleteWithHeaders(context.Background(), "test", nil, nil)
+	resp, err := service.DeleteWithHeaders(t.Context(), "test", nil, nil)
 
 	require.NoError(t, err)
 	assert.Equal(t, http.StatusOK, resp.StatusCode)
@@ -540,7 +540,7 @@ func TestHttpService_DeleteCBOpenRequests(t *testing.T) {
 
 	// Perform test cases
 	for _, tc := range testCases {
-		resp, err := service.Delete(context.Background(), tc.path, nil)
+		resp, err := service.Delete(t.Context(), tc.path, nil)
 
 		if tc.expectErr {
 			require.Error(t, err)
@@ -571,7 +571,7 @@ func TestHttpService_DeleteWithHeaderCBOpenRequests(t *testing.T) {
 
 	// Perform test cases
 	for _, tc := range testCases {
-		resp, err := service.DeleteWithHeaders(context.Background(), tc.path, nil, nil)
+		resp, err := service.DeleteWithHeaders(t.Context(), tc.path, nil, nil)
 
 		if tc.expectErr {
 			require.Error(t, err)
diff --git a/pkg/gofr/service/custom_header_test.go b/pkg/gofr/service/custom_header_test.go
index d1909c9e..4808ce2e 100644
--- a/pkg/gofr/service/custom_header_test.go
+++ b/pkg/gofr/service/custom_header_test.go
@@ -1,7 +1,6 @@
 package service
 
 import (
-	"context"
 	"io"
 	"net/http"
 	"net/http/httptest"
@@ -40,7 +39,7 @@ func Test_CustomDomainProvider_Get(t *testing.T) {
 			},
 		})
 
-	resp, err := customHeaderService.Get(context.Background(), "/path", queryParams)
+	resp, err := customHeaderService.Get(t.Context(), "/path", queryParams)
 	require.NoError(t, err)
 
 	defer resp.Body.Close()
@@ -73,7 +72,7 @@ func Test_CustomDomainProvider_Post(t *testing.T) {
 				"TEST_KEY": "test_value",
 			}})
 
-	resp, err := customHeaderService.Post(context.Background(), "/path", queryParams, body)
+	resp, err := customHeaderService.Post(t.Context(), "/path", queryParams, body)
 	require.NoError(t, err)
 
 	defer resp.Body.Close()
@@ -102,7 +101,7 @@ func TestCustomDomainProvider_Put(t *testing.T) {
 				"TEST_KEY": "test_value",
 			}})
 
-	resp, err := customHeaderService.Put(context.Background(), "/path", queryParams, body)
+	resp, err := customHeaderService.Put(t.Context(), "/path", queryParams, body)
 	require.NoError(t, err)
 
 	defer resp.Body.Close()
@@ -131,7 +130,7 @@ func TestCustomDomainProvider_Patch(t *testing.T) {
 				"TEST_KEY": "test_value",
 			}})
 
-	resp, err := customHeaderService.Patch(context.Background(), "/path", queryParams, body)
+	resp, err := customHeaderService.Patch(t.Context(), "/path", queryParams, body)
 	require.NoError(t, err)
 
 	defer resp.Body.Close()
@@ -159,7 +158,7 @@ func TestCustomDomainProvider_Delete(t *testing.T) {
 				"TEST_KEY": "test_value",
 			}})
 
-	resp, err := customHeaderService.Delete(context.Background(), "/path", body)
+	resp, err := customHeaderService.Delete(t.Context(), "/path", body)
 	require.NoError(t, err)
 
 	defer resp.Body.Close()
diff --git a/pkg/gofr/service/health_test.go b/pkg/gofr/service/health_test.go
index 821cb8f3..d037b8e4 100644
--- a/pkg/gofr/service/health_test.go
+++ b/pkg/gofr/service/health_test.go
@@ -1,7 +1,6 @@
 package service
 
 import (
-	"context"
 	"encoding/json"
 	"fmt"
 	"net/http"
@@ -24,7 +23,7 @@ func TestHTTPService_HealthCheck(t *testing.T) {
 		"method", http.MethodGet, "status", fmt.Sprintf("%v", http.StatusOK)).Times(1)
 
 	// when params value is of type []string then last value is sent in request
-	resp := service.HealthCheck(context.Background())
+	resp := service.HealthCheck(t.Context())
 
 	assert.Equal(t, &Health{Status: serviceUp, Details: map[string]any{"host": server.URL[7:]}},
 		resp, "TEST[%d], Failed.\n%s")
@@ -38,7 +37,7 @@ func TestHTTPService_HealthCheckCustomURL(t *testing.T) {
 		"method", http.MethodGet, "status", fmt.Sprintf("%v", http.StatusOK)).Times(1)
 
 	// when params value is of type []string then last value is sent in request
-	resp := service.HealthCheck(context.Background())
+	resp := service.HealthCheck(t.Context())
 
 	assert.Equal(t, &Health{Status: serviceUp, Details: map[string]any{"host": server.URL[7:]}},
 		resp, "TEST[%d], Failed.\n%s")
@@ -54,7 +53,7 @@ func TestHTTPService_HealthCheckErrorResponse(t *testing.T) {
 	service := NewHTTPService("http://test", logging.NewMockLogger(logging.INFO), metrics)
 
 	// when params value is of type []string then last value is sent in request
-	resp := service.HealthCheck(context.Background())
+	resp := service.HealthCheck(t.Context())
 
 	body, _ := json.Marshal(&resp)
 
@@ -69,7 +68,7 @@ func TestHTTPService_HealthCheckDifferentStatusCode(t *testing.T) {
 		"method", http.MethodGet, "status", fmt.Sprintf("%v", http.StatusBadRequest)).AnyTimes()
 
 	// when params value is of type []string then last value is sent in request
-	resp := service.HealthCheck(context.Background())
+	resp := service.HealthCheck(t.Context())
 
 	assert.Equal(t, &Health{Status: serviceDown,
 		Details: map[string]any{"host": server.URL[7:], "error": "service down"}},
@@ -92,7 +91,7 @@ func TestHTTPService_HealthCheckTimeout(t *testing.T) {
 		service := NewHTTPService(server.URL, logging.NewMockLogger(logging.INFO), metrics,
 			&HealthConfig{HealthEndpoint: ".well-known/alive", Timeout: 1})
 
-		resp := service.HealthCheck(context.Background())
+		resp := service.HealthCheck(t.Context())
 
 		assert.Equal(t, &Health{Status: serviceDown,
 			Details: map[string]any{"error": "Get \"" + server.URL + "/.well-known/alive\": context deadline exceeded"}},
diff --git a/pkg/gofr/service/new_test.go b/pkg/gofr/service/new_test.go
index fd0e3f53..d6b64a45 100644
--- a/pkg/gofr/service/new_test.go
+++ b/pkg/gofr/service/new_test.go
@@ -1,7 +1,6 @@
 package service
 
 import (
-	"context"
 	"fmt"
 	"io"
 	"net/http"
@@ -37,7 +36,7 @@ func TestNewHTTPService(t *testing.T) {
 func TestHTTPService_createAndSendRequest(t *testing.T) {
 	ctrl := gomock.NewController(t)
 	metrics := NewMockMetrics(ctrl)
-	ctx := context.Background()
+	ctx := t.Context()
 
 	tests := []struct {
 		desc           string
@@ -128,7 +127,7 @@ func TestHTTPService_Get(t *testing.T) {
 
 	// TODO : Nil Correlation ID is coming in logs, it has to be fixed
 
-	resp, err := service.Get(context.Background(), "test-path",
+	resp, err := service.Get(t.Context(), "test-path",
 		map[string]any{"key": "value", "name": []string{"gofr", "test"}})
 
 	if resp != nil {
@@ -160,7 +159,7 @@ func TestHTTPService_GetWithHeaders(t *testing.T) {
 
 	// TODO : Nil Correlation ID is coming in logs, it has to be fixed
 
-	resp, err := service.GetWithHeaders(context.Background(), "test-path",
+	resp, err := service.GetWithHeaders(t.Context(), "test-path",
 		map[string]any{"key": "value", "name": []string{"gofr", "test"}},
 		map[string]string{"header1": "value1"})
 
@@ -201,7 +200,7 @@ func TestHTTPService_Put(t *testing.T) {
 
 	// TODO : Nil Correlation ID is coming in logs, it has to be fixed
 
-	resp, err := service.Put(context.Background(), "test-path",
+	resp, err := service.Put(t.Context(), "test-path",
 		map[string]any{"key": "value", "name": []string{"gofr", "test"}}, []byte("{Test Body}"))
 
 	if resp != nil {
@@ -242,7 +241,7 @@ func TestHTTPService_PutWithHeaders(t *testing.T) {
 
 	// TODO : Nil Correlation ID is coming in logs, it has to be fixed
 
-	resp, err := service.PutWithHeaders(context.Background(), "test-path",
+	resp, err := service.PutWithHeaders(t.Context(), "test-path",
 		map[string]any{"key": "value", "name": []string{"gofr", "test"}}, []byte("{Test Body}"),
 		map[string]string{"header1": "value1"})
 
@@ -283,7 +282,7 @@ func TestHTTPService_Patch(t *testing.T) {
 
 	// TODO : Nil Correlation ID is coming in logs, it has to be fixed
 
-	resp, err := service.Patch(context.Background(), "test-path",
+	resp, err := service.Patch(t.Context(), "test-path",
 		map[string]any{"key": "value", "name": []string{"gofr", "test"}}, []byte("{Test Body}"))
 
 	if resp != nil {
@@ -324,7 +323,7 @@ func TestHTTPService_PatchWithHeaders(t *testing.T) {
 
 	// TODO : Nil Correlation ID is coming in logs, it has to be fixed
 
-	resp, err := service.PutWithHeaders(context.Background(), "test-path",
+	resp, err := service.PutWithHeaders(t.Context(), "test-path",
 		map[string]any{"key": "value", "name": []string{"gofr", "test"}}, []byte("{Test Body}"),
 		map[string]string{"header1": "value1"})
 
@@ -365,7 +364,7 @@ func TestHTTPService_Post(t *testing.T) {
 
 	// TODO : Nil Correlation ID is coming in logs, it has to be fixed
 
-	resp, err := service.Post(context.Background(), "test-path",
+	resp, err := service.Post(t.Context(), "test-path",
 		map[string]any{"key": "value", "name": []string{"gofr", "test"}}, []byte("{Test Body}"))
 
 	if resp != nil {
@@ -406,7 +405,7 @@ func TestHTTPService_PostWithHeaders(t *testing.T) {
 
 	// TODO : Nil Correlation ID is coming in logs, it has to be fixed
 
-	resp, err := service.PostWithHeaders(context.Background(), "test-path",
+	resp, err := service.PostWithHeaders(t.Context(), "test-path",
 		map[string]any{"key": "value", "name": []string{"gofr", "test"}}, []byte("{Test Body}"),
 		map[string]string{"header1": "value1"})
 
@@ -446,7 +445,7 @@ func TestHTTPService_Delete(t *testing.T) {
 
 	// TODO : Nil Correlation ID is coming in logs, it has to be fixed
 
-	resp, err := service.Delete(context.Background(), "test-path", []byte("{Test Body}"))
+	resp, err := service.Delete(t.Context(), "test-path", []byte("{Test Body}"))
 
 	if resp != nil {
 		defer resp.Body.Close()
@@ -485,7 +484,7 @@ func TestHTTPService_DeleteWithHeaders(t *testing.T) {
 
 	// TODO : Nil Correlation ID is coming in logs, it has to be fixed
 
-	resp, err := service.DeleteWithHeaders(context.Background(), "test-path", []byte("{Test Body}"),
+	resp, err := service.DeleteWithHeaders(t.Context(), "test-path", []byte("{Test Body}"),
 		map[string]string{"header1": "value1"})
 
 	if resp != nil {
@@ -503,7 +502,7 @@ func TestHTTPService_createAndSendRequestCreateRequestFailure(t *testing.T) {
 		Logger: logging.NewMockLogger(logging.INFO),
 	}
 
-	ctx := context.Background()
+	ctx := t.Context()
 	// when params value is of type []string then last value is sent in request
 	resp, err := service.createAndSendRequest(ctx,
 		"!@#$", "test-path", map[string]any{"key": "value", "name": []string{"gofr", "test"}},
@@ -528,7 +527,7 @@ func TestHTTPService_createAndSendRequestServerError(t *testing.T) {
 		Metrics: metrics,
 	}
 
-	ctx := context.Background()
+	ctx := t.Context()
 
 	metrics.EXPECT().RecordHistogram(gomock.Any(), "app_http_service_response", gomock.Any(), "path", gomock.Any(),
 		"method", http.MethodPost, "status", fmt.Sprintf("%v", http.StatusInternalServerError))
diff --git a/pkg/gofr/service/oauth_test.go b/pkg/gofr/service/oauth_test.go
index 26b08ca0..a219fdcd 100644
--- a/pkg/gofr/service/oauth_test.go
+++ b/pkg/gofr/service/oauth_test.go
@@ -1,7 +1,6 @@
 package service
 
 import (
-	"context"
 	"net/http"
 	"net/http/httptest"
 	"strings"
@@ -84,7 +83,7 @@ func TestHttpService_GetSuccessRequestsOAuth(t *testing.T) {
 
 	service := setupHTTPServiceTestServerForOAuth(server)
 
-	resp, err := service.Get(context.Background(), "test", nil)
+	resp, err := service.Get(t.Context(), "test", nil)
 
 	assert.Equal(t, http.StatusOK, resp.StatusCode)
 	require.NoError(t, err)
@@ -97,7 +96,7 @@ func TestHttpService_PostSuccessRequestsOAuth(t *testing.T) {
 
 	service := setupHTTPServiceTestServerForOAuth(server)
 
-	resp, err := service.Post(context.Background(), "test", nil, nil)
+	resp, err := service.Post(t.Context(), "test", nil, nil)
 
 	assert.Equal(t, http.StatusOK, resp.StatusCode)
 	require.NoError(t, err)
@@ -110,7 +109,7 @@ func TestHttpService_PatchSuccessRequestsOAuth(t *testing.T) {
 
 	service := setupHTTPServiceTestServerForOAuth(server)
 
-	resp, err := service.Patch(context.Background(), "test", nil, nil)
+	resp, err := service.Patch(t.Context(), "test", nil, nil)
 
 	assert.Equal(t, http.StatusOK, resp.StatusCode)
 	require.NoError(t, err)
@@ -123,7 +122,7 @@ func TestHttpService_PutSuccessRequestsOAuth(t *testing.T) {
 
 	service := setupHTTPServiceTestServerForOAuth(server)
 
-	resp, err := service.Put(context.Background(), "test", nil, nil)
+	resp, err := service.Put(t.Context(), "test", nil, nil)
 
 	assert.Equal(t, http.StatusOK, resp.StatusCode)
 	require.NoError(t, err)
@@ -136,7 +135,7 @@ func TestHttpService_DeleteSuccessRequestsOAuth(t *testing.T) {
 
 	service := setupHTTPServiceTestServerForOAuth(server)
 
-	resp, err := service.Delete(context.Background(), "test", nil)
+	resp, err := service.Delete(t.Context(), "test", nil)
 
 	assert.Equal(t, http.StatusOK, resp.StatusCode)
 	require.NoError(t, err)
@@ -147,7 +146,7 @@ func TestHttpService_DeleteSuccessRequestsOAuth(t *testing.T) {
 func TestHttpService_DeleteRequestsOAuthError(t *testing.T) {
 	service := setupHTTPServiceTestServerForOAuthWithUnSupportedMethod()
 
-	resp, err := service.Delete(context.Background(), "test", nil)
+	resp, err := service.Delete(t.Context(), "test", nil)
 
 	assert.Nil(t, resp)
 	require.ErrorContains(t, err, `unsupported protocol scheme`)
@@ -160,7 +159,7 @@ func TestHttpService_DeleteRequestsOAuthError(t *testing.T) {
 func TestHttpService_PutRequestsOAuthError(t *testing.T) {
 	service := setupHTTPServiceTestServerForOAuthWithUnSupportedMethod()
 
-	resp, err := service.Put(context.Background(), "test", nil, nil)
+	resp, err := service.Put(t.Context(), "test", nil, nil)
 
 	assert.Nil(t, resp)
 	require.ErrorContains(t, err, `unsupported protocol scheme`)
@@ -173,7 +172,7 @@ func TestHttpService_PutRequestsOAuthError(t *testing.T) {
 func TestHttpService_PatchRequestsOAuthError(t *testing.T) {
 	service := setupHTTPServiceTestServerForOAuthWithUnSupportedMethod()
 
-	resp, err := service.Patch(context.Background(), "test", nil, nil)
+	resp, err := service.Patch(t.Context(), "test", nil, nil)
 
 	assert.Nil(t, resp)
 	require.ErrorContains(t, err, `unsupported protocol scheme`)
@@ -186,7 +185,7 @@ func TestHttpService_PatchRequestsOAuthError(t *testing.T) {
 func TestHttpService_PostRequestsOAuthError(t *testing.T) {
 	service := setupHTTPServiceTestServerForOAuthWithUnSupportedMethod()
 
-	resp, err := service.Post(context.Background(), "test", nil, nil)
+	resp, err := service.Post(t.Context(), "test", nil, nil)
 
 	assert.Nil(t, resp)
 	require.ErrorContains(t, err, `unsupported protocol scheme`)
@@ -199,7 +198,7 @@ func TestHttpService_PostRequestsOAuthError(t *testing.T) {
 func TestHttpService_GetRequestsOAuthError(t *testing.T) {
 	service := setupHTTPServiceTestServerForOAuthWithUnSupportedMethod()
 
-	resp, err := service.Get(context.Background(), "test", nil)
+	resp, err := service.Get(t.Context(), "test", nil)
 
 	assert.Nil(t, resp)
 	require.ErrorContains(t, err, `unsupported protocol scheme`)
diff --git a/pkg/gofr/service/retry_test.go b/pkg/gofr/service/retry_test.go
index 31d25704..fc72e4ae 100644
--- a/pkg/gofr/service/retry_test.go
+++ b/pkg/gofr/service/retry_test.go
@@ -77,7 +77,7 @@ func TestRetryProvider_Get(t *testing.T) {
 	retryHTTP := retryConfig.AddOption(mockHTTP)
 
 	// Make the GET request
-	resp, err := retryHTTP.Get(context.Background(), "/test", nil)
+	resp, err := retryHTTP.Get(t.Context(), "/test", nil)
 	require.NoError(t, err)
 
 	defer resp.Body.Close()
@@ -91,7 +91,7 @@ func TestRetryProvider_GetWithHeaders(t *testing.T) {
 	retryHTTP := retryConfig.AddOption(mockHTTP)
 
 	// Make the GET request with headers
-	resp, err := retryHTTP.GetWithHeaders(context.Background(), "/test", nil,
+	resp, err := retryHTTP.GetWithHeaders(t.Context(), "/test", nil,
 		map[string]string{"Content-Type": "application/json"})
 	require.NoError(t, err)
 
@@ -106,7 +106,7 @@ func TestRetryProvider_Post(t *testing.T) {
 	retryHTTP := retryConfig.AddOption(mockHTTP)
 
 	// Make the POST request
-	resp, err := retryHTTP.Post(context.Background(), "/test", nil, []byte("body"))
+	resp, err := retryHTTP.Post(t.Context(), "/test", nil, []byte("body"))
 	require.NoError(t, err)
 
 	defer resp.Body.Close()
@@ -120,7 +120,7 @@ func TestRetryProvider_PostWithHeaders(t *testing.T) {
 	retryHTTP := retryConfig.AddOption(mockHTTP)
 
 	// Make the POST request with headers
-	resp, err := retryHTTP.PostWithHeaders(context.Background(), "/test", nil, []byte("body"),
+	resp, err := retryHTTP.PostWithHeaders(t.Context(), "/test", nil, []byte("body"),
 		map[string]string{"Content-Type": "application/json"})
 	require.NoError(t, err)
 
@@ -135,7 +135,7 @@ func TestRetryProvider_Put(t *testing.T) {
 	retryHTTP := retryConfig.AddOption(mockHTTP)
 
 	// Make the PUT request
-	resp, err := retryHTTP.Put(context.Background(), "/test", nil, []byte("body"))
+	resp, err := retryHTTP.Put(t.Context(), "/test", nil, []byte("body"))
 	require.NoError(t, err)
 
 	defer resp.Body.Close()
@@ -149,7 +149,7 @@ func TestRetryProvider_PutWithHeaders(t *testing.T) {
 	retryHTTP := retryConfig.AddOption(mockHTTP)
 
 	// Make the PUT request with headers
-	resp, err := retryHTTP.PutWithHeaders(context.Background(), "/test", nil, []byte("body"),
+	resp, err := retryHTTP.PutWithHeaders(t.Context(), "/test", nil, []byte("body"),
 		map[string]string{"Content-Type": "application/json"})
 	require.NoError(t, err)
 
@@ -173,7 +173,7 @@ func TestRetryProvider_Patch_WithError(t *testing.T) {
 		&RetryConfig{MaxRetries: 5})
 
 	// Make the PATCH request
-	resp, err := httpService.Patch(context.Background(), "/test", nil, []byte("body"))
+	resp, err := httpService.Patch(t.Context(), "/test", nil, []byte("body"))
 	require.NoError(t, err)
 
 	defer resp.Body.Close()
@@ -187,7 +187,7 @@ func TestRetryProvider_PatchWithHeaders(t *testing.T) {
 	retryHTTP := retryConfig.AddOption(mockHTTP)
 
 	// Make the PATCH request with headers
-	resp, err := retryHTTP.PatchWithHeaders(context.Background(), "/test", nil, []byte("body"),
+	resp, err := retryHTTP.PatchWithHeaders(t.Context(), "/test", nil, []byte("body"),
 		map[string]string{"Content-Type": "application/json"})
 	require.NoError(t, err)
 
@@ -202,7 +202,7 @@ func TestRetryProvider_Delete(t *testing.T) {
 	retryHTTP := retryConfig.AddOption(mockHTTP)
 
 	// Make the DELETE request
-	resp, err := retryHTTP.Delete(context.Background(), "/test", nil)
+	resp, err := retryHTTP.Delete(t.Context(), "/test", nil)
 	require.NoError(t, err)
 
 	defer resp.Body.Close()
@@ -215,7 +215,7 @@ func TestRetryProvider_DeleteWithHeaders(t *testing.T) {
 	retryHTTP := retryConfig.AddOption(mockHTTP)
 
 	// Make the DELETE request with headers
-	resp, err := retryHTTP.DeleteWithHeaders(context.Background(), "/test", []byte("body"),
+	resp, err := retryHTTP.DeleteWithHeaders(t.Context(), "/test", []byte("body"),
 		map[string]string{"Content-Type": "application/json"})
 	require.NoError(t, err)
 
diff --git a/pkg/gofr/shutdown_test.go b/pkg/gofr/shutdown_test.go
index 7da17af5..cc64fd50 100644
--- a/pkg/gofr/shutdown_test.go
+++ b/pkg/gofr/shutdown_test.go
@@ -19,7 +19,7 @@ func TestShutdownWithContext_ContextTimeout(t *testing.T) {
 		return nil
 	}
 
-	ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond)
+	ctx, cancel := context.WithTimeout(t.Context(), 100*time.Millisecond)
 	defer cancel()
 
 	err := ShutdownWithContext(ctx, mockShutdownFunc, nil)
@@ -35,7 +35,7 @@ func TestShutdownWithContext_SuccessfulShutdown(t *testing.T) {
 		return nil
 	}
 
-	ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
+	ctx, cancel := context.WithTimeout(t.Context(), 1*time.Second)
 	defer cancel()
 
 	err := ShutdownWithContext(ctx, mockShutdownFunc, nil)
diff --git a/pkg/gofr/subscriber_test.go b/pkg/gofr/subscriber_test.go
index b766b307..6179096d 100644
--- a/pkg/gofr/subscriber_test.go
+++ b/pkg/gofr/subscriber_test.go
@@ -80,7 +80,7 @@ func TestSubscriptionManager_HandlerError(t *testing.T) {
 
 		// Run the subscriber in a goroutine
 		go func() {
-			err := subscriptionManager.startSubscriber(context.Background(), "test-topic",
+			err := subscriptionManager.startSubscriber(t.Context(), "test-topic",
 				func(*Context) error {
 					return handleError("error in test-topic")
 				})
@@ -112,7 +112,7 @@ func TestSubscriptionManager_SubscribeError(t *testing.T) {
 
 		// Run the subscriber in a goroutine
 		go func() {
-			err := subscriptionManager.startSubscriber(context.Background(), "abc",
+			err := subscriptionManager.startSubscriber(t.Context(), "abc",
 				func(*Context) error {
 					return handleError("error in abc")
 				})
@@ -144,7 +144,7 @@ func TestSubscriptionManager_PanicRecovery(t *testing.T) {
 
 		// Run the subscriber in a goroutine
 		go func() {
-			_ = subscriptionManager.startSubscriber(context.Background(), "abc",
+			_ = subscriptionManager.startSubscriber(t.Context(), "abc",
 				func(*Context) error {
 					panic("test panic")
 				})
@@ -163,7 +163,7 @@ func TestSubscriptionManager_PanicRecovery(t *testing.T) {
 }
 
 func TestSubscriptionManager_ShouldStopOnCtxDone(t *testing.T) {
-	ctx, cancel := context.WithCancel(context.Background())
+	ctx, cancel := context.WithCancel(t.Context())
 
 	mockContainer := container.Container{
 		Logger: logging.NewLogger(logging.ERROR),
diff --git a/pkg/gofr/websocket/websocket_test.go b/pkg/gofr/websocket/websocket_test.go
index 5e663365..a8fbf8de 100644
--- a/pkg/gofr/websocket/websocket_test.go
+++ b/pkg/gofr/websocket/websocket_test.go
@@ -1,7 +1,6 @@
 package websocket
 
 import (
-	"context"
 	"net/http"
 	"net/http/httptest"
 	"os"
@@ -120,7 +119,7 @@ func Test_Upgrade(t *testing.T) {
 
 	wsUpgrader := WSUpgrader{Upgrader: mockUpgrader}
 
-	req, err := http.NewRequestWithContext(context.TODO(), http.MethodGet, "/", http.NoBody)
+	req, err := http.NewRequestWithContext(t.Context(), http.MethodGet, "/", http.NoBody)
 	require.NoError(t, err)
 
 	w := httptest.NewRecorder()