How is engine thrust measured in flight? When aircraft engines are evaluated in a test flight, how is the thrust of the engine measured?

You would need accurate thrust numbers to calculate the real-world specific fuel consumption (i.e. not in a controlled environment like an engine on a test bed).

I'd assume it is nearly impossible to measure thrust indirectly with any accuracy since so many factors are involved (wing shape, wind, air density, lift, ...).

So I guess there should be a way to measure thrust directly, probably in the engine pylon.

So how is engine thrust measured in flight?
VectorVictor gives the right answer for jets.

However, for propeller aircraft this is really hard, and in the end only the difference between drag and thrust can be measured. By measuring the brake power of the static engine and the drag of the aircraft in a windtunnel, some data points can be acquired which help in calculating what the real thrust in flight could have been.

You are right, in the end it is impossible to produce a precise measurement of thrust. The most important part of the measurement is actually a precise definition of what thrust is: How do you account for the increased friction drag in the propeller slipstream? Is cooling drag part of the airframe drag, or should it reduce thrust? Measuring thrust is foremost an exercise in precise, meticulous bookkeeping.