Dalarna University's logo and link to the university's website

du.sePublications
Change search
CiteExportLink to record
Permanent link

Direct link
Cite
Citation style
  • apa
  • ieee
  • modern-language-association-8th-edition
  • vancouver
  • chicago-author-date
  • chicago-note-bibliography
  • Other style
More styles
Language
  • de-DE
  • en-GB
  • en-US
  • fi-FI
  • nn-NO
  • nn-NB
  • sv-SE
  • Other locale
More languages
Output format
  • html
  • text
  • asciidoc
  • rtf
Enhetstestning med Generativ AI: Möjligheter och utmaningar
Dalarna University, School of Information and Engineering.
Dalarna University, School of Information and Engineering.
2025 (Swedish)Independent thesis Basic level (degree of Bachelor), 10 credits / 15 HE creditsStudent thesisAlternative title
Unit Testing with Generative AI : Opportunities and challenges (English)
Abstract [sv]

Under den senaste tiden har generativ AI tagit världen med storm. Där det lanserats många olika modeller som är gratis att använda eller som har en kostnad. Dessa generativa modeller används inom olika branscher men även av enskilda individer.

Generativ AI kan användas inom många områden, till exempel för att generera kod, text eller bilder. Parallellt med detta har det börjat forskas om hur AI kan användas inom mjukvarutestning. Tidigare studier har visat på att enhetstester ofta bortprioriteras på grund av sin resurskrävande natur. På grund av detta har det utförts en fallstudie där författarna genererar enhetstestester med olika generativa AI modeller. För att studera om AI kan användas för att generera enhetstester, med syfte att analysera möjliga tidsbesparingar, noggrannhet, tillförlitlighet och brister. Datamaterialet har samlats in med kvantitativa och kvalitativa metoder. Testerna har genererats med Chat-GPT, CoPilot, Llama, DeepSeek och Gemini.

Slutsatsen resulterade i att skapandet av enhetstester med generativ AI är effektivt. Då tidsskillnaden mellan att generera- och manuellt skapa enhetstester är cirka 34 timmar. De generativa modellerna genererade även enhetstest som var tillförlitliga. Där författarna kunde se att testen täcker många utfall och uppnå kodtäckning värden runt 85%. Genom att använda en mer effektiv prompt, genererades mer exakta och precisa tester.

Det upptäcktes även att samma generativa AI modeller genererade duplicerade testfall, där testerna som genererats var helt- eller nära identiska. Även spår av hallucinationer upptäcktes då det genererades ny kod, påhittade metoder och kodklasser i vissa fall. Kommunikationsproblem var ett återkommande problem, där den generativa AI modellen inte gjorde exakt enligt prompten. Detta problem uppstod ej vid användningen av en mer effektiv prompt.

Abstract [en]

Recently, generative AI has taken the world by storm. Where many different models have been launched that are free to use or that have a cost. These generative models are used in different industries but also by individuals.

Generative AI can be used in many areas, for example to generate code, text or images. In parallel with this, research has begun on how AI can be used in software testing. Previous studies have shown that unit tests are often deprioritized due to their resource-intensive nature. Because of this, a case study has been conducted in which the authors generate unit tests with different generative AI models. To study whether AI can be used to generate unit tests, with the aim of analyzing possible time savings, accuracy, reliability and deficiencies. The data has been collected using quantitative and qualitative methods. The tests have been generated with Chat-GPT, CoPilot, Llama, DeepSeek and Gemini.

The study findings lead to the conclusion that creating unit tests with generative AI is effective. Since the time difference between generating and manually creating unit tests is around 34 working hours. The generative models also generated unit tests that were reliable. Where the tests cover many outcomes and get coverage values around 85%. By using a more efficient prompt, more accurate and precise tests were generated.

It was also discovered that the same generative AI models generated duplicate testcases, where the tests generated were completely or nearly identical. Traces of hallucinations were also discovered when new code was generated, invented methods and code classes in some cases. Communication problems were a recurring problem, where the generative AI model did not do exactly according to the prompt. This problem did not occur when using a more efficient prompt. 

Place, publisher, year, edition, pages
2025.
Keywords [en]
AI, Unit testing, Generative AI, Code coverage, Code generation
National Category
Software Engineering
Identifiers
URN: urn:nbn:se:du-50769OAI: oai:DiVA.org:du-50769DiVA, id: diva2:1975621
External cooperation
Sogeti
Subject / course
Microdata Analysis
Available from: 2025-06-24 Created: 2025-06-24 Last updated: 2025-10-09

Open Access in DiVA

fulltext(987 kB)59 downloads
File information
File name FULLTEXT01.pdfFile size 987 kBChecksum SHA-512
e46807bb2512b5e55491f40e72006fe470ccc0afab3c7b6059d28ba7e2fbac56db93a70fd390e87b70ca1173c89c454e183859e4dee4c7c8b9b4dafcb125af30
Type fulltextMimetype application/pdf

By organisation
School of Information and Engineering
Software Engineering

Search outside of DiVA

GoogleGoogle Scholar
Total: 59 downloads
The number of downloads is the sum of all downloads of full texts. It may include eg previous versions that are now no longer available

urn-nbn

Altmetric score

urn-nbn
Total: 131 hits
CiteExportLink to record
Permanent link

Direct link
Cite
Citation style
  • apa
  • ieee
  • modern-language-association-8th-edition
  • vancouver
  • chicago-author-date
  • chicago-note-bibliography
  • Other style
More styles
Language
  • de-DE
  • en-GB
  • en-US
  • fi-FI
  • nn-NO
  • nn-NB
  • sv-SE
  • Other locale
More languages
Output format
  • html
  • text
  • asciidoc
  • rtf