You can exchange a valid UK driving licence without taking a test within 9 months of the date that the UK leaves the EU. After this 9 month period you will need to take a test in order to exchange your licence.

For information, visit the Spanish Directorate-General for Traffic website (in Spanish only).