انتقل إلى المحتوى
أمين أبوزيد
درس مخطط لهJNR-046-L02

REST Assured

  • الدرس 2 من 5
  • Junior
في هذا الدرس 4 موضوعات

هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.

نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.

في هذا الدرس

write readable HTTP tests.

الموضوعات المخطط لها

  • REST Assured uses given / when / then to send requests and check responses. Verify the current version before recording.
  • Set the port from @LocalServerPort.
  • Check status, headers, and body fields with JSON paths: body("items.size()", is(2)).
  • extract().path(...) pulls a value for the next step (for example a token or id).
  • Check body fields that matter, not the whole JSON string.
تفاصيل المخطط المبدئي

عرض عملي

java
given().port(port).contentType(JSON).body(newOrder)
.when().post("/api/orders")
.then().statusCode(201)
    .header("Location", containsString("/api/orders/"))
    .body("status", equalTo("NEW"));

اختبر فهمك

Why not compare the entire JSON string?

أظهر الإجابة

It breaks on harmless changes such as field order or new fields.

التطبيق

طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.

المختبر والتمارين الاختبار

تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.

اكتب للبحث في المستويات والمراحل والوحدات والدروس.