{"id":"b7f549f0bbd11db2","repo":"stretchr/testify","slug":"copy-is-deprecated","errorCode":null,"errorMessage":"Copy() is deprecated","messagePattern":"Copy\\(\\) is deprecated","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"assert/assertions.go","lineNumber":2071,"sourceCode":"// Errorf collects the error.\nfunc (c *CollectT) Errorf(format string, args ...interface{}) {\n\tc.errors = append(c.errors, fmt.Errorf(format, args...))\n}\n\n// FailNow stops execution by calling runtime.Goexit.\nfunc (c *CollectT) FailNow() {\n\tc.fail()\n\truntime.Goexit()\n}\n\n// Deprecated: That was a method for internal usage that should not have been published. Now just panics.\nfunc (*CollectT) Reset() {\n\tpanic(\"Reset() is deprecated\")\n}\n\n// Deprecated: That was a method for internal usage that should not have been published. Now just panics.\nfunc (*CollectT) Copy(TestingT) {\n\tpanic(\"Copy() is deprecated\")\n}\n\nfunc (c *CollectT) fail() {\n\tif !c.failed() {\n\t\tc.errors = []error{} // Make it non-nil to mark a failure.\n\t}\n}\n\nfunc (c *CollectT) failed() bool {\n\treturn c.errors != nil\n}\n\n// EventuallyWithT asserts that given condition will be met in waitFor time,\n// periodically checking target function each tick. In contrast to Eventually,\n// it supplies a CollectT to the condition function, so that the condition\n// function can use the CollectT to call other assertions.\n// The condition is considered \"met\" if no errors are raised in a tick.\n// The supplied CollectT collects all errors from one tick (if there are any).","sourceCodeStart":2053,"sourceCodeEnd":2089,"githubUrl":"https://github.com/stretchr/testify/blob/001eb7946baf451879253643e4ce4b38eaa0d4a7/assert/assertions.go#L2053-L2089","documentation":"CollectT.Copy() (assert/assertions.go:2070) is an unconditionally panicking stub marked Deprecated. Like Reset, it was an internal method that leaked into the public API and was removed; calling it always panics. It was intended to copy collected errors onto another TestingT.","triggerScenarios":"Calling collectT.Copy(otherT) on a *assert.CollectT — typically legacy code that manually propagated collected errors to a real *testing.T.","commonSituations":"Code written against an old testify version where Copy was functional; copy-pasted patterns from deprecated docs; upgrading testify and hitting the panic at runtime.","solutions":["Replace Copy(t) with manual error propagation: iterate collectT.Errors() and call t.Errorf for each.","Use assert.Fail or the modern CollectT integration with EventuallyWithT which handles propagation automatically.","Delete the Copy call if the errors are no longer needed on the target."],"exampleFix":"// before\ncollectT.Copy(t)\n// after\nfor _, e := range collectT.Errors() {\n    t.Errorf(\"%v\", e)\n}","handlingStrategy":"validation","validationCode":"// Static prevention: replace collectT.Copy(t) with manual propagation.\nfunc propagateErrors(c *assert.CollectT, t *testing.T) {\n    for _, e := range c.Errors() {\n        t.Errorf(\"%v\", e)\n    }\n}","typeGuard":null,"tryCatchPattern":"// Copy() always panics; recover is pointless.\n// Use the manual propagation helper above in place of Copy.","preventionTips":["After upgrading testify, grep for '.Copy(' on CollectT and replace.","Track the changelog entry that removed Copy.","Centralize CollectT error propagation in one helper."],"tags":["deprecated","collectt","panic","api-removal"],"analyzedSha":"001eb7946baf451879253643e4ce4b38eaa0d4a7","analyzedAt":"2026-08-04T21:49:58.715Z","schemaVersion":2}