You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We want to add unit tests for the **ShoppingCart** class. Let’s ask Amazon Q Developer to create unit tests for **ShoppingCart**. We also want Amazon Q Developer to follow the existing pattern of creating test classes in a separate test project.
@@ -48,14 +52,26 @@ By default, the agentic experience is on. If you are in the planning phase of th
48
52
49
53
Then, we ask Q Developer *“Can you create a test for @ShoppingCart.cs? Look at existing test and use the same libraries”*. First, notice that we are giving a command instead of just asking a question. Second, we are referencing the file ShoppingCart.cs explicitly to provide Q Developer the appropriate context. In the following image, you can see that Q Developer is acting on our behalf. In agentic coding mode, Q Developer can take actions and run commands. In our example, it is reading files, writing to files, and running commands with your permission.
Using commands, Q Developer was able to analyze our solution structure, understand that we have a project called **Bookstore.Domain.Tests**, and create a new file containing unit tests for **ShoppingCart**.
We can verify that there is a new file called **ShoppingCartTests** in the **Bookstore.Domain.Tests** project, which is aligned with our existing test creation strategy.
@@ -64,20 +80,28 @@ In the following example, we will demonstrate the power of the agentic coding ex
64
80
65
81
In our example, we have deliberately misspelled one of the methods in the **IShoppingCartRepository** interface. The **AddAsync** method is now incorrectly spelled **AddAsyn**.
When we try to build the **Bookstore.Domain** project, we get a build error as expected. Let’s ask Q Developer to fix the error. Without the agentic coding experience, we would have to copy the text of the build error into the chat window and ask Q Developer to provide recommendations. Then we would have to act on its recommendations by manually making changes and trying to build. This is one of many examples of the power of the agentic chat, which runs commands and uses the command’s output to enrich the context of the prompt to take actions.
70
88
71
89
With the agentic coding experience, we just ask Q Developer *“Can you fix the error I am getting while building the solution? Please build and check it”*. In the following image, you will see how Q Developer runs the .NET build commands to get build errors and read the relevant files.
After it reads the files, it finds the spelling mistake and fixes it automatically. As shown in the following image, it then builds the solution to verify that its fix worked.
In the following image, Amazon Q Developer provides a summary of the error, the actions it took to build it. It even helps me with some recommendations to fix the warnings it got while running the build.
Chúng ta muốn thêm unit tests cho lớp **ShoppingCart**. Hãy nhờ Amazon Q Developer tạo unit tests cho **ShoppingCart**. Chúng tôi cũng muốn Amazon Q Developer tuân theo pattern hiện có là tạo test classes trong một project test riêng biệt.
@@ -49,16 +53,26 @@ Theo mặc định, trải nghiệm agentic được bật. Nếu bạn đang tr
49
53
50
54
Sau đó, chúng tôi hỏi Q Developer: *“Can you create a test for @ShoppingCart.cs? Look at existing test and use the same libraries.”* Đầu tiên, hãy chú ý rằng chúng tôi đưa ra một command thay vì chỉ đặt câu hỏi. Thứ hai, chúng tôi tham chiếu rõ ràng file ShoppingCart.cs để cung cấp context phù hợp cho Q Developer. Trong hình tiếp theo, bạn có thể thấy rằng Q Developer đang hành động thay mặt chúng tôi. Trong chế độ agentic coding, Q Developer có thể thực hiện hành động và chạy commands. Trong ví dụ của chúng tôi, nó đang đọc file, ghi vào file, và chạy commands với sự cho phép của bạn.
Bằng cách dùng commands, Q Developer có thể phân tích cấu trúc solution của chúng tôi, hiểu rằng chúng tôi có một project tên là **Bookstore.Domain.Tests**, và tạo một file mới chứa unit tests cho **ShoppingCart**.
@@ -67,20 +81,28 @@ Trong ví dụ tiếp theo, chúng tôi sẽ minh họa sức mạnh của trả
67
81
68
82
Trong ví dụ, chúng tôi cố ý viết sai chính tả một method trong interface **IShoppingCartRepository**. Method **AddAsync** đã bị viết sai thành **AddAsyn**.
Khi chúng tôi cố gắng build project **Bookstore.Domain**, chúng tôi nhận được build error như mong đợi. Hãy nhờ Q Developer sửa lỗi này. Nếu không có agentic coding experience, chúng tôi sẽ phải copy text của build error vào cửa sổ chat và yêu cầu Q Developer đưa ra khuyến nghị. Sau đó chúng tôi sẽ phải làm theo khuyến nghị bằng cách chỉnh sửa thủ công và thử build lại. Đây chỉ là một trong nhiều ví dụ về sức mạnh của agentic chat, cái có thể chạy commands và dùng output của commands để làm giàu context cho prompt nhằm thực hiện hành động.
73
89
74
90
Với agentic coding experience, chúng tôi chỉ cần hỏi Q Developer: *“Can you fix the error I am getting while building the solution? Please build and check it.”* Trong hình dưới đây, bạn sẽ thấy Q Developer chạy các lệnh build .NET để lấy build errors và đọc các file liên quan.
Trong hình tiếp theo, Amazon Q Developer cung cấp một bản tóm tắt của lỗi, các hành động nó đã thực hiện để build, và thậm chí giúp tôi với một số khuyến nghị để sửa các warnings mà nó gặp trong khi chạy build.
In the following image, Amazon Q Developer provides a summary of the error, the actions it took to build it. It even helps me with some recommendations to fix the warnings it got while running the build.
0 commit comments