# tmuxtest.NewSession

- **Module:** tmuxtest
- **Package:** github.com/libtmux/libtmux-go/tmux
- **Language:** Go
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-go/blob/5f808882015a975a65acc7f9da5b3ff0d5cbdc91/tmux/tmuxtest/resources.go#L29
- **Page:** https://libtmux.org/reference/go/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.
