# Depth test -opengl

Does depth test runs before fragment shader,hence not even processing the fragment with frag shader if fragment is discarded Or It first runs the fragment shader and then depth test I.e. fragment shader runs for even the discarded frags.

If prior is false,then can it be achieved some how?

If your fragment shader writes to gl_FragDepth it will do the depth test after your shader.
If you leave gl_FragDepth alone it will do the depth test before your shader.