Detained antivirus software entrepreneur John McAfee testified in a Spanish court Tuesday as part of his fight against extradition to the United States, where he is wanted on tax-related criminal charges that carry a prison sentence of up to 30 years.