I've never been satisfied with how this has been handled in any sci-fi story I've read, watched, etc. It always seems to get handwaved away with "we have sensor packages of various powers" and "they have stealth capabilities of various effectivenesses". I want to get much more specific than that.
Try to keep this within the realm of basic plausibility and Clarke's Third Law. I want technology in this future warfare to be advanced, but still basically within the realm of what we currently know to be plausible.
This is what I've been able to come up with:
Visual sensing; video collection and analysis comparable to modern day techniques, like what guides the FGM-148 Javelin. In space there's no ambient light, which already presents difficulties with shadows cast by planets, moons, and even other large ships, which would effectively create blind spots unless searchlights were used (which would immediately reveal the craft carrying the light). Add to this that warships will almost certainly be painted matte black, and I don't think visual sensing will be a reliable means at all.
Thermal sensing; works like visual sensing, but with the benefit that spacecraft will emit this naturally (blackbody radiation), so there's no worry about shadows and such. Ships could theoretically defeat this with cooling systems built into their hull plating, but my concern would be that supercooling the hull enough to appear invisible against the black background of space would severely compromise its structural integrity, especially if it includes complex elements like reactive armor. Protruding sensory packages and weapons, and also engines also wouldn't be able to be cooled in this manner without losing all functionality. The best countermeasure I can come up with for thermal sensing would be dispersing a wide cloud of superheated gas around your craft to disguise it (like an IR smoke screen), but I can't imagine this would last long; the cloud would either disperse or cool rapidly, and would need constant renewal to remain effective.
Radar; similar to the current technology. Although we currently have the means to almost completely defeat it (our only current barrier is cost, and this will likely vanish in the future), I'm not certain how the detection could also evolve in the future. In any case, sending out radar signals would probably also allow the detected craft to see the source of the incoming signals, and would compromise the position of the broadcasting craft.