The difference between a case study and a testimonial is who is talking. A testimonial is a customer saying you were good, which readers discount because businesses only publish favourable ones. A case study is you describing a problem and a result, with enough detail that the reader can evaluate whether it applies to them. The second survives scepticism because it contains checkable specifics.
Structure it as a story rather than as a summary. The situation before, what was actually wrong, what you did and why you chose that approach, and what the outcome was. The why is the part most businesses omit and the part that demonstrates judgement, because anybody can list actions and the reasoning is what distinguishes somebody who understood the problem.
Include numbers wherever you have them, and be precise rather than impressive. Revenue increased by a stated amount, enquiries went from one figure to another, a process that took a stated number of hours now takes fewer. Vague improvements such as significantly increased are read as nothing, and a modest specific number is considerably more credible than a large unspecific one.
Include what it cost. This is the detail businesses most often withhold and the one readers most want, because the entire question a prospect is holding is whether this is achievable for them. A case study without a cost is an interesting story about somebody else. One with a cost is a comparison the reader can make.
Get permission properly and in writing, particularly for anything naming the client or including their numbers. Ask before writing rather than afterward, show them the draft, and accept edits. Some clients will decline to be named and will agree to an anonymised version, which is worth having, though it loses some of the credibility that a named business provides.
Write about failures and difficulties as well as successes, or at least the parts that were hard. A case study where everything proceeded smoothly reads as marketing. One that names a complication and how it was resolved reads as an account of real work, and it also demonstrates how you behave when something goes wrong, which is what a prospect is actually trying to learn.
Keep them short enough to be read. A page is sufficient, and businesses routinely produce documents nobody finishes. If there is more to say, the additional detail belongs further down for the small number of readers who want it rather than in front of everybody.
Publish them where a prospect will encounter them at the moment of deciding, which means on the relevant service page rather than in a separate section nobody visits. A case study filed under case studies is read by people already convinced. The same one on the page describing that service is read by people choosing.
Then produce them as you go rather than intending to. The details fade quickly, the numbers become difficult to retrieve, and the client becomes harder to reach. Writing a short account at the point a project completes takes half an hour and is considerably better than the version you would reconstruct a year later.
Take the photographs and the numbers while the work is happening rather than intending to gather them afterward. Before and after images, the measurement you took at the start, and the figure at the end are all easy to capture at the time and frequently impossible to reconstruct later, which is why so many good projects never become case studies.