寄る and 通る: stopping at a shop and passing in front of it
Compare visiting a pharmacy with taking a route past it, without inferring whether a visit occurred from passage alone.
Stopping at a place
寄る, read よる, can describe stopping somewhere along the way. 帰りに薬局に寄りました。 says that someone stopped at the pharmacy on the way back.
郵便局に寄ってから会社へ行きます。 says that someone will stop at the post office before going to work. Separate the initial visit from the later destination.
Passing through a place or in front of it
通る, read とおる, describes using a route. 薬局の前を通りました。 says that someone passed in front of the pharmacy. The sentence does not specify whether they also visited it.
会社へ行く途中で公園を通ります。 says that someone passes through the park on the way to work. The park is the route, and the company is the destination.
Passage and a visit can both occur
店の前を通ってから、中に入りました。 says that someone passed in front of the shop and then entered it. 通る does not negate the later visit.
店には寄らず、前を通っただけです。 says that someone only passed in front of the shop without stopping there. 寄らず explicitly states that no visit occurred.
Does 薬局の前を通りました。 prove that the person did not visit the pharmacy?
Show the answer and why
No. It only says that the person passed in front of the pharmacy. Not visiting needs a separate expression such as 寄らず.

