A Search-Based Testing Framework for Deep Neural Networks of Source Code EmbeddingA Search-Based Testing Framework for Deep Neural Networks of Source Code Embedding
The researchers propose a search-based testing framework for deep neural networks that embed source code, usable for testing models on downstream tasks such as code search. The framework uses mainstream code refactoring tools to generate semantically equivalent code variants as test inputs, and uses DNN mutation testing to guide the testing direction. A large-scale evaluation on source code processing models based on code embedding methods such as Code2vec, Code2seq, and CodeBERT shows that the generated adversarial samples reduce the performance of these models by 5.41% to 9.58% on average; after retraining with adversarial samples, model robustness improves by 23.05% on average. The evaluation also shows that, compared with other methods, this adversarial test generation strategy has the smallest negative impact on model performance on regular test data, with a median of 3.56%.