# tmuxtest.NewSession

- **Module:** tmuxtest
- **Package:** github.com/libtmux/libtmux-go/tmux
- **Language:** Go
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-go/blob/52968a3181c1c9e6d1b26c565d4b170968ae61c0/tmux/tmuxtest/resources.go#L29
- **Page:** https://libtmux.org/en/go/latest/reference/tmuxtest-newsession/

```
tmuxtest.NewSession(ctx: context.Context, t: testing.TB, server: tmux.Server, request: tmux.NewSessionRequest) -> tmux.Session
```

NewSession creates a test-owned [tmux.Session] and registers cleanup against its stable ID. An empty [tmux.NewSessionRequest.Name] receives a collision-checked temporary name. The request and referenced values are copied before tmux is called, and setup failures call [testing.TB.Fatal]. Cleanup belongs to t rather than ctx and continues to target the session if it is renamed.
