diff --git a/content/en/docs/marketplace/manage-content/create-content/create-connectors/connector-best-practices/testing.md b/content/en/docs/marketplace/manage-content/create-content/create-connectors/connector-best-practices/testing.md index e989203bbfa..bae446371e0 100644 --- a/content/en/docs/marketplace/manage-content/create-content/create-connectors/connector-best-practices/testing.md +++ b/content/en/docs/marketplace/manage-content/create-content/create-connectors/connector-best-practices/testing.md @@ -6,13 +6,17 @@ weight: 12 ## Introduction -You can use the [Unit Testing](/appstore/modules/unit-testing/) module to test Mendix by calling microflows for whole pieces of functionality. Use unit tests for smaller, more targeted tests at the method-level of your Java code. +You can use [testflows](/refguide/testflows/) or the [Unit Testing](/appstore/modules/unit-testing/) module to test Mendix by calling microflows for whole pieces of functionality. Use unit tests for smaller, more targeted tests at the method-level of your Java code. As with any automated testing, it is a great supplement for capturing known, expected behavior. For capturing unknown behavior, Mendix recommends risk-based exploratory testing. ## Testing Microflows -Use the Mendix app where you built the module to test your module. The Unit Testing module can help call microflows and actions to aid in testing. See [Testing Microflows with the Unit Testing Module](/refguide/testing-microflows-with-unit-testing-module/) for more information. +Use the Mendix app where you built the module to test your module. + +In Studio Pro 11.18 and above, you can use [testflows](/refguide/testflows/), which are in beta. A testflow calls the microflows of your module and uses [Assert](/refguide/assert/) activities to check the results. You run testflows from the [Test Runner](/refguide/test-runner/) pane, and each testflow runs in its own runtime with an in-memory database. Testflows are intended to replace the Unit Testing module. + +In earlier versions of Studio Pro, the Unit Testing module can help call microflows and actions to aid in testing. For more information, see the [Testing with the Unit Testing Module](/refguide/testing-microflows-with-unit-testing-module/#unit-testing-module) section in *Testing Microflows*. ## Java Unit Tests {#unit-testing} diff --git a/content/en/docs/marketplace/platform-supported-content/modules/unit-testing.md b/content/en/docs/marketplace/platform-supported-content/modules/unit-testing.md index ad5b9388fbe..17e8571aacd 100644 --- a/content/en/docs/marketplace/platform-supported-content/modules/unit-testing.md +++ b/content/en/docs/marketplace/platform-supported-content/modules/unit-testing.md @@ -7,6 +7,10 @@ description: "Describes the configuration and usage of the Unit Testing module, ## Introduction +{{% alert color="info" %}} +Studio Pro 11.18 introduces [testflows](/refguide/testflows/) in beta. Testflows let you test your microflow logic in Studio Pro, without installing a module, and they are intended to replace the Unit Testing module. For more information, see [Testflows](/refguide/testflows/). +{{% /alert %}} + The [Unit Testing](https://marketplace.mendix.com/link/component/390/) module enables developers to implement, run, and manage unit tests within Mendix applications. You can test your microflows, Java actions, and other logic by implementing test microflows and JUnit (Java) tests. Use the module to automate testing, detect issues early, and improve code quality. ### Limitations @@ -208,4 +212,4 @@ The `completed` value will be `false` as long as the test run is not finished. T ## Read More -* [Testing Microflows with the Unit Testing Module](/refguide/testing-microflows-with-unit-testing-module/) +* [Testing Microflows](/refguide/testing-microflows-with-unit-testing-module/) diff --git a/content/en/docs/refguide/modeling/app-explorer/modules/_index.md b/content/en/docs/refguide/modeling/app-explorer/modules/_index.md index 9b89266c9ec..60983ea342a 100644 --- a/content/en/docs/refguide/modeling/app-explorer/modules/_index.md +++ b/content/en/docs/refguide/modeling/app-explorer/modules/_index.md @@ -39,6 +39,7 @@ There are the following type of modules: | --- | --- | --- | | [Pages](/refguide/pages/) | [Data view](/refguide/data-view/), [data grid](/refguide/data-grid/), [table](/refguide/table/), [text box](/refguide/text-box/) | Forms are used to create a user interface for the end-user. They are composed of components that are called [widgets](/appstore/widgets/). | | [Microflows](/refguide/microflows/) | [Activities](/refguide/activities/), [sequence Flow](/refguide/sequence-flow/) | Microflows describe the logic of your app. They are composed of activities that manipulate objects and interact with the client. | +| [Testflows](/refguide/testflows/) (beta) | [Assert](/refguide/assert/), [activities](/refguide/activities/) | Testflows test the logic of your app. You create them in the **Testing** node of a module and run them from the [Test Runner](/refguide/test-runner/) pane. | | [Enumerations](/refguide/enumerations/) | | An enumeration is a set of predefined values (for example, in a web shop, an enumeration called MemberType could have the values Gold and Silver). | ## Page Resources diff --git a/content/en/docs/refguide/modeling/application-logic/_index.md b/content/en/docs/refguide/modeling/application-logic/_index.md index be7df617122..4a6459d4cfd 100644 --- a/content/en/docs/refguide/modeling/application-logic/_index.md +++ b/content/en/docs/refguide/modeling/application-logic/_index.md @@ -15,7 +15,7 @@ Application logic in Mendix can be implemented via [microflows](/refguide/microf Microflows and nanoflows are short-lived in nature. They can perform actions such as creating and updating objects, customizing button functionalities, showing pages, and making choices. For example, you can use a microflow to customize a **Save** button for validating end-users' input data. For more instructions, see the [Creating Application Logic](/quickstarts/part1/#create-application-logic) section in *Building a Responsive Web App*. An example of a nanoflow is to use it to create a button that allows end-users to take a picture. For more instructions, see the [Creating Application Logic](/quickstarts/part2/#creating-application-logic) section in *Adding a Native Mobile App*. -Microflows run in the runtime server and can therefore not be used in offline apps, while nanoflows run directly on the client side (that is, on the browser/device), and can be used in an offline app. For more details on their differences, see the [Differences between Microflows and Nanoflows](/refguide/microflows-and-nanoflows/#differences) section in *Microflows and Nanoflows*. +Microflows run in the runtime server and can therefore not be used in offline apps, while nanoflows run directly on the client side (that is, on the browser/device), and can be used in an offline app. For more details on their differences, see the [Differences between Microflows and Nanoflows](/refguide/microflows-and-nanoflows/#differences) section in *Microflows, Nanoflows, and Testflows*. Workflows represent a long-lived process. They are used to build extendable processes and are fully integrated with other editors, such as the microflow editor and the page editor. The main difference of workflows from microflows and nanoflows is from a waiting aspect—the workflow is paused until it gets an input from an end-user. An example of a workflow is when an employee sends a business travel request to get approved by their manager. Sending the travel request will trigger the start of the workflow and then the workflow is paused until a manager approves or rejects the request by clicking a button. For more information on workflow definitions, properties, and usages, see [Workflows](/refguide/workflows/). diff --git a/content/en/docs/refguide/modeling/application-logic/microflows-and-nanoflows/_index.md b/content/en/docs/refguide/modeling/application-logic/microflows-and-nanoflows/_index.md index 8d1c4ff75ca..0b2647ee7ab 100644 --- a/content/en/docs/refguide/modeling/application-logic/microflows-and-nanoflows/_index.md +++ b/content/en/docs/refguide/modeling/application-logic/microflows-and-nanoflows/_index.md @@ -1,18 +1,21 @@ --- -title: "Microflows and Nanoflows" +title: "Microflows, Nanoflows, and Testflows" url: /refguide/microflows-and-nanoflows/ weight: 10 -description: "Presents an overview of microflows and nanoflows." +description: "Presents an overview of microflows, nanoflows, and testflows." --- ## Introduction Microflows and nanoflows allow you to express the logic of your application. They can perform actions such as creating and updating objects, showing pages, and making choices. It is a visual way of expressing what traditionally ends up in textual program code. -Explore the documentation for details on microflow and nanoflow definitions, properties, and usages. +Testflows use the same visual language to test the logic of your application. For more information, see [Testflows](/refguide/testflows/). + +Explore the documentation for details on microflow, nanoflow, and testflow definitions, properties, and usages. * [Microflows](/refguide/microflows/) * [Nanoflows](/refguide/nanoflows/) +* [Testflows](/refguide/testflows/) * [Sequence Flow](/refguide/sequence-flow/) * [Activities](/refguide/activities/) * [Decisions](/refguide/decisions/) @@ -49,3 +52,17 @@ Below presents a list of main differences between microflows and nanoflows: * Because nanoflows use JavaScript libraries and microflows use Java libraries, there can sometimes be slight differences in the way [expressions](/refguide/expressions/) are executed. * When used in nanoflow activities, expressions do not support the following objects and variables: `$latestSoapFault`, `$latestHttpResponse`, `$currentSession`, `$currentUser`, `$currentDeviceType`. * Nanoflows are not run inside a transaction. So, if an error occurs in a nanoflow, it will not roll back any previous changes. + +## Testflows {#testflows} + +{{% alert color="warning" %}} This feature is in beta. For more information, see [Release Status](/releasenotes/release-status/). {{% /alert %}} + +Testflows test the logic of your app. You build a testflow in the same way as a microflow, and like microflows, testflows run in the runtime server. A testflow can use the same activities as a microflow, plus [testing activities](/refguide/activities/#testing-activities) such as Assert, which check whether your logic gives the result you expect. + +Testflows differ from microflows in the following ways: + +* You create testflows in the **Testing** node of a module. +* A testflow cannot have parameters and does not return a value. +* You do not call a testflow from your app. Instead, you run testflows from the **Test Runner** pane in Studio Pro. + +For more information, see [Testflows](/refguide/testflows/). diff --git a/content/en/docs/refguide/modeling/application-logic/microflows-and-nanoflows/activities/_index.md b/content/en/docs/refguide/modeling/application-logic/microflows-and-nanoflows/activities/_index.md index d159786e215..0e7491a9640 100644 --- a/content/en/docs/refguide/modeling/application-logic/microflows-and-nanoflows/activities/_index.md +++ b/content/en/docs/refguide/modeling/application-logic/microflows-and-nanoflows/activities/_index.md @@ -6,12 +6,14 @@ weight: 40 ## Introduction -Activities define the actions that are executed in a microflow or a nanoflow. +Activities define the actions that are executed in a microflow, a nanoflow, or a testflow. There are different types of activity, and they are grouped together in the Studio Pro **Toolbox**. All the activities are listed below. Click on each activity for more details. {{% alert color="info" %}} -Most activities can be used in both microflows and nanoflows. However, some can only be used in one of these types of flow, or the behavior may differ between in microflows and in nanoflows. For more information, see the [Differences between Microflows and Nanoflows](/refguide/microflows-and-nanoflows/#differences) section in *Microflows and Nanoflows*. +Most activities can be used in both microflows and nanoflows. However, some can only be used in one of these types of flow, or the behavior may differ between in microflows and in nanoflows. For more information, see the [Differences between Microflows and Nanoflows](/refguide/microflows-and-nanoflows/#differences) section in *Microflows, Nanoflows, and Testflows*. + +A [testflow](/refguide/testflows/) can use all the activities that are available in microflows, as well as [testing activities](#testing-activities). {{% /alert %}} ## Object Activities @@ -122,6 +124,20 @@ These activities can only be used in microflows. | {{< figure src="/attachments/refguide/modeling/application-logic/microflows-and-nanoflows/activities/increment-counter.png" alt="increment-counter" link="/refguide/metrics-increment-counter/" max-width=55% class="no-border" >}} | [Increment counter](/refguide/metrics-increment-counter/) | Allows you to increment a counter by 1. | | {{< figure src="/attachments/refguide/modeling/application-logic/microflows-and-nanoflows/activities/gauge.png" alt="gauge" link="/refguide/metrics-gauge/" max-width=55% class="no-border" >}} | [Gauge](/refguide/metrics-gauge/) | Allows you to specify the value of a gauge. | +## Testing Activities {#testing-activities} + +{{% alert color="warning" %}} This feature is in beta. For more information, see [Release Status](/releasenotes/release-status/). {{% /alert %}} + +{{% alert color="info" %}} +These activities can only be used in [testflows](/refguide/testflows/). +{{% /alert %}} + +[Testing activities](/refguide/testing-activities/) are used to check the results of the logic you test. + +| Name | Description | +| --- | --- | +| [Assert](/refguide/assert/) | Checks whether a condition is true. If the condition is not true, the testflow stops and fails. | + ## Email Activities {{% alert color="info" %}} diff --git a/content/en/docs/refguide/modeling/application-logic/microflows-and-nanoflows/activities/testing-activities/_index.md b/content/en/docs/refguide/modeling/application-logic/microflows-and-nanoflows/activities/testing-activities/_index.md new file mode 100644 index 00000000000..e355e15b073 --- /dev/null +++ b/content/en/docs/refguide/modeling/application-logic/microflows-and-nanoflows/activities/testing-activities/_index.md @@ -0,0 +1,26 @@ +--- +title: "Testing Activities" +url: /refguide/testing-activities/ +weight: 83 +description: "Describes the testing activities that you can use in testflows." +beta: true +--- + +{{% alert color="warning" %}} This feature is in beta. For more information, see [Release Status](/releasenotes/release-status/). {{% /alert %}} + +{{% alert color="info" %}} +These activities can only be used in testflows. +{{% /alert %}} + +## Introduction + +The activities described in this document are in the **Testing activities** section of the **Toolbox**. This section is only available when you edit a [testflow](/refguide/testflows/). + +The following are the testing activities you can use in your testflow: + +* [Assert](/refguide/assert/) – checks whether a condition is true, and stops and fails the testflow if it is not + +## Read More + +* [Testflows](/refguide/testflows/) +* [Activities](/refguide/activities/) diff --git a/content/en/docs/refguide/modeling/application-logic/microflows-and-nanoflows/activities/testing-activities/assert.md b/content/en/docs/refguide/modeling/application-logic/microflows-and-nanoflows/activities/testing-activities/assert.md new file mode 100644 index 00000000000..abd0bf7b983 --- /dev/null +++ b/content/en/docs/refguide/modeling/application-logic/microflows-and-nanoflows/activities/testing-activities/assert.md @@ -0,0 +1,75 @@ +--- +title: "Assert" +url: /refguide/assert/ +weight: 10 +description: "Describes the Assert activity, which checks a condition in a testflow." +beta: true +--- + +{{% alert color="warning" %}} This feature is in beta. For more information, see [Release Status](/releasenotes/release-status/). {{% /alert %}} + +{{% alert color="info" %}} +This activity can only be used in testflows. +{{% /alert %}} + +## Introduction + +The **Assert** activity checks whether a condition is true. Use it in a [testflow](/refguide/testflows/) to check that the logic you test gives the result you expect, for example that a microflow returns the right value or changes an object in the right way. + +If the condition is true, the testflow continues. If the condition is not true, the Assert activity fails: the testflow stops immediately and the **Test Runner** pane shows the testflow as failed, together with the failure message. + +A testflow passes when it reaches its end without a failed Assert activity or another error. + +## Properties + +The **Assert** properties pane consists of the following sections: + +* [Action](#action) +* [Common](#common) + +## Action Section {#action} + +The **Action** section of the properties pane shows the action associated with this activity. + +You can open a dialog box to configure this action by clicking the ellipsis (**…**) next to the action. + +You can also open the dialog box by double-clicking the activity, or right-clicking the activity and selecting **Properties**. + +### Target Expression {#target-expression} + +The condition that you want to check. The target expression is an [expression](/refguide/expressions/) that must evaluate to a Boolean. The Assert activity passes when the expression evaluates to `true`, and fails otherwise. + +This property is required. + +For example, to check that a microflow called from the testflow returned a total of 100, use the following target expression: + +```text +$Total = 100 +``` + +### Failure Result Expression {#failure-result-expression} + +The message that is shown when the Assert activity fails. The failure result expression is an [expression](/refguide/expressions/) that must evaluate to a string. Use it to explain what went wrong, for example by including the actual value: + +```text +'Expected a total of 100, but the total was ' + toString($Total) +``` + +This property is optional. If you do not set it, or if it does not evaluate to a string, the failure message names the target expression that did not evaluate to `true`. + +## Common Section {#common} + +{{% snippet file="/static/_includes/refguide/microflow-common-section-link.md" %}} + +## Error Handling {#error-handling} + +A failed Assert activity must always stop the testflow, so that the test fails. For this reason, the following rules apply: + +* The [error handling type](/refguide/microflow-element-common-properties/#error-handling) of an Assert activity is always **Rollback**. You cannot choose another error handling type. +* If you place an Assert activity inside a [loop](/refguide/loop/), the error handling type of that loop must be **Rollback**. This also applies to every loop that contains that loop. Otherwise, the loop would continue with the next iteration after a failed Assert activity, and Studio Pro shows a consistency error. + +## Read More + +* [Testflows](/refguide/testflows/) +* [Testing Activities](/refguide/testing-activities/) +* [Error Handling in Microflows](/refguide/error-handling-in-microflows/) diff --git a/content/en/docs/refguide/modeling/application-logic/microflows-and-nanoflows/microflows/_index.md b/content/en/docs/refguide/modeling/application-logic/microflows-and-nanoflows/microflows/_index.md index 1f180631217..5336bc6d443 100644 --- a/content/en/docs/refguide/modeling/application-logic/microflows-and-nanoflows/microflows/_index.md +++ b/content/en/docs/refguide/modeling/application-logic/microflows-and-nanoflows/microflows/_index.md @@ -10,7 +10,7 @@ description: "Presents an overview of all the elements that can be used in a mic Microflows allow you to express the logic of your application. A microflow can perform actions such as creating and updating objects, showing pages, and making choices. It is a visual way of expressing what traditionally ends up in textual program code. -Microflows run in the runtime server and can therefore not be used in offline apps. For application logic within offline apps, see [Nanoflows](/refguide/nanoflows/). For information on how nanoflows and microflows differ, see the [Differences between Microflows and Nanoflows](/refguide/microflows-and-nanoflows/#differences) section in *Microflows and Nanoflows*. +Microflows run in the runtime server and can therefore not be used in offline apps. For application logic within offline apps, see [Nanoflows](/refguide/nanoflows/). For information on how nanoflows and microflows differ, see the [Differences between Microflows and Nanoflows](/refguide/microflows-and-nanoflows/#differences) section in *Microflows, Nanoflows, and Testflows*. This page is a summary of the elements which make up a microflow, together with their visual representation within the microflow. It also covers [keyboard support](#keyboard) when editing microflows. diff --git a/content/en/docs/refguide/modeling/application-logic/microflows-and-nanoflows/microflows/testing-microflows-with-unit-testing.md b/content/en/docs/refguide/modeling/application-logic/microflows-and-nanoflows/microflows/testing-microflows-with-unit-testing.md index ad39cc7e166..87aa335c2f6 100644 --- a/content/en/docs/refguide/modeling/application-logic/microflows-and-nanoflows/microflows/testing-microflows-with-unit-testing.md +++ b/content/en/docs/refguide/modeling/application-logic/microflows-and-nanoflows/microflows/testing-microflows-with-unit-testing.md @@ -1,37 +1,121 @@ --- -title: "Testing Microflows with the Unit Testing Module" -linktitle: "Testing Microflows with Unit Test Module" +title: "Testing Microflows" url: /refguide/testing-microflows-with-unit-testing-module/ weight: 3 +description: "Describes how to test microflows with testflows or with the Unit Testing module." --- ## Introduction -The [Unit Testing](/appstore/modules/unit-testing/) module provides the capabilities to verify if your [microflow](/refguide/microflows/) logic and your custom Java code works as expected. It provides a user-friendly interface to manage and run unit tests that are created by using microflows, as well as unit tests that are by created using JUnit. +You can test whether your [microflow](/refguide/microflows/) logic works as expected in two ways: + +* With [testflows](/refguide/testflows/), which are built into Studio Pro 11.18 and above. Testflows are in beta and are intended to replace the Unit Testing module. +* With the [Unit Testing](/appstore/modules/unit-testing/) module, which you install from the Marketplace. Besides microflow tests, this module also supports unit tests that are created using JUnit. This how-to teaches you how to do the following: -* Set up the Unit Testing module -* Unit test a microflow +* Create a sample microflow to test +* Test the microflow with testflows +* Set up the Unit Testing module and test the microflow with it ## Prerequisites -Before starting this how-to, make sure you have completed the following prerequisites: +Before starting this how-to, download [Mendix Studio Pro](https://marketplace.mendix.com/link/studiopro/). To use testflows, you need Studio Pro 11.18 or above. + +## Creating a Sample Microflow for Testing {#sample-microflow} + +For the purpose of this how-to, create a sample microflow that you can then test with testflows or with the Unit Testing module. In a real-life scenario, the steps below may be different, depending on the microflow that you want to create. + +To create a sample microflow for testing, create a [new app](/refguide/new-app/) and follow these steps: + +1. Create a new [enumeration](/refguide/configuring-a-domain-model/#add-enumeration) with the following properties: + * **Name** – *Level* + * **Enumeration values** **Caption** and **Name** – *Junior*, *Medior*, and *Senior*. + + {{< figure src="/attachments/refguide/modeling/application-logic/microflows-and-nanoflows/microflows/testing/create-level-enumeration.png" alt="Enumeration with three values" max-width=70% >}} + +2. Open the domain model of **MyFirstModule**. +3. Create a new [entity](/refguide/configuring-a-domain-model/#create-entity) with the following properties: + * **Name** – *Employee* + * **Attributes** – *Name* (of the **String** type) and *Level* ( of the **Enumeration** > **Level** type). + + {{< figure src="/attachments/refguide/modeling/application-logic/microflows-and-nanoflows/microflows/testing/employee-entity.png" alt="A view of the Employee entity used by the sample microflow" max-width=80% >}} + +4. Create a microflow called **Promote** that changes the **Level** attribute of the **Employee** entity based on the enumeration value: + * For the **Change Employee's level to Medior** activity, set the **Level** value to *MyFirstModule.Level.Medior* + * For the **Change Employee's level to Senior** activity, set the **Level** value to *MyFirstModule.Level.Senior* + + {{< figure src="/attachments/refguide/modeling/application-logic/microflows-and-nanoflows/microflows/testing/promote-microflow.png" alt="A view of the sample Promote microflow" max-width=80% >}} + +{{% alert color="info" %}}As a best practice, do not test every microflow in your application. Instead, test your most essential microflows.{{% /alert %}} + +## Testing with Testflows {#testflows} + +{{% alert color="warning" %}} This feature is in beta. For more information, see [Release Status](/releasenotes/release-status/). {{% /alert %}} + +This section describes how to create testflows for the sample microflow described in the [Creating a Sample Microflow for Testing](#sample-microflow) section above. In a real-life scenario, the steps below may be different, depending on the microflow that you want to test. For more information on testflows, see [Testflows](/refguide/testflows/). + +### Creating a Testflow {#create-testflow} + +To create a testflow for the **Promote** microflow, follow these steps: + +1. In the App Explorer, expand **MyFirstModule**, right-click the **Testing** node, and then click **Add testflow**. +2. In the **Name** field, enter *PromoteEmployeeToMedior*. +3. In the **PromoteEmployeeToMedior** testflow, add a new **Create object** activity for the **Employee** entity with the following members: + * **Name** – *'John'* + * **Level** – *MyFirstModule.Level.Junior* +4. Add a **Call microflow** activity that calls the **MyFirstModule.Promote** microflow, with *$NewEmployee* as the argument for the **Employee** parameter. +5. To test if the employee is promoted to the right level, add an [Assert](/refguide/assert/) activity from the **Testing activities** section of the **Toolbox**, with the following properties: + * **Target expression** – *$NewEmployee/Level = MyFirstModule.Level.Medior* + * **Failure result expression** – *'Expected employee level to be Medior. Actual value: ' + getCaption($NewEmployee/Level)* +6. Right-click the **Assert** activity, select **Edit caption**, and then enter *Promoted to Medior?* for the new caption. +7. Connect the activities from the start event to the end event. +8. In the **Testing** node, duplicate the **PromoteEmployeeToMedior** testflow twice, and then rename the new testflows in the following way: + * *PromoteEmployeeToSenior* + * *EmployeeStillSenior* +9. In the **PromoteEmployeeToSenior** testflow: + * Set the value of the **Level** member to *MyFirstModule.Level.Medior* for the **Create object** activity. + * Set the following values for the **Assert** activity: + * **Target expression** – *$NewEmployee/Level = MyFirstModule.Level.Senior* + * **Failure result expression** – *'Expected employee level to be Senior. Actual value: ' + getCaption($NewEmployee/Level)* + * Caption – *Promoted to Senior?* +10. In the **EmployeeStillSenior** testflow: + * Set the value of the **Level** member to *MyFirstModule.Level.Senior* for the **Create object** activity. + * Set the following values for the **Assert** activity: + * **Target expression** – *$NewEmployee/Level = MyFirstModule.Level.Senior* + * **Failure result expression** – *'Expected employee level to be Senior. Actual value: ' + getCaption($NewEmployee/Level)* + * Caption – *Employee still Senior?* + +### Running the Testflows {#run-testflows} -* Download [Mendix Studio Pro](https://marketplace.mendix.com/link/studiopro/) -* Review the Marketplace components used in this how-to: +To run the testflows, follow these steps: - | Component | Version Used in This How-to | - | --- | --- | - | [Unit Testing](/appstore/modules/unit-testing/) | 9.6.0 | +1. Click **View** > **Test Runner** to open the [Test Runner](/refguide/test-runner/) pane. +2. Click **Run all**. - {{% alert color="info" %}}All the images, names, and steps in this how-to are based on the Marketplace component versions listed above. When using later versions of this content, images or names on your screen may be different than shown in this how-to.{{% /alert %}} + If your app is running locally, Studio Pro asks you to confirm that it can stop the app. Each testflow runs in a dedicated runtime with its own in-memory database, so the test data does not end up in the database of your app. -## Setting up the Unit Testing Module +3. Verify that all the testflows pass. To see the result of a testflow, select it in the tree. If a testflow fails, the **Result** section shows the failure message of the Assert activity that failed. + +## Testing with the Unit Testing Module {#unit-testing-module} + +The [Unit Testing](/appstore/modules/unit-testing/) module provides the capabilities to verify if your microflow logic and your custom Java code works as expected. It provides a user-friendly interface to manage and run unit tests that are created by using microflows, as well as unit tests that are created by using JUnit. + +### Prerequisites for the Unit Testing Module {#unit-testing-prerequisites} + +Review the Marketplace components used in this section: + +| Component | Version Used in This How-to | +| --- | --- | +| [Unit Testing](/appstore/modules/unit-testing/) | 9.6.0 | + +{{% alert color="info" %}}All the images, names, and steps in this section are based on the Marketplace component versions listed above. When using later versions of this content, images or names on your screen may be different than shown in this how-to.{{% /alert %}} + +### Setting up the Unit Testing Module {#setup-unit-testing} To set up the unit testing module and run the example tests, follow these steps: -1. Create a [new app](/refguide/new-app/). +1. Open the app that contains the [sample microflow](#sample-microflow). 2. Download and install the [Unit Testing](https://marketplace.mendix.com/link/component/390) module. For more information, see [How to Use Marketplace Content](/appstore/use-content/). @@ -73,41 +157,10 @@ To set up the unit testing module and run the example tests, follow these steps: 17. To view detailed test results, click **Details** in the **UnitTesting.Test_ValidUnitTest** row. -## Unit Testing a Microflow - -In this section, you will learn how to create and run a microflow unit test. - -### Creating a Sample Microflow for Testing {#sample-microflow} - -For the purpose of this how-to, create a sample microflow that you can then test with unit testing. In a real-life scenario, the steps below may be different, depending on the microflow that you want to create. - -To create a sample microflow for testing, follow these steps: - -1. Create a new [enumeration](/refguide/configuring-a-domain-model/#add-enumeration) with the following properties: - * **Name** – *Level* - * **Enumeration values** **Caption** and **Name** – *Junior*, *Medior*, and *Senior*. - - {{< figure src="/attachments/refguide/modeling/application-logic/microflows-and-nanoflows/microflows/testing/create-level-enumeration.png" alt="Enumeration with three values" max-width=70% >}} - -2. Open the domain model of **MyFirstModule**. -3. Create a new [entity](/refguide/configuring-a-domain-model/#create-entity) with the following properties: - * **Name** – *Employee* - * **Attributes** – *Name* (of the **String** type) and *Level* ( of the **Enumeration** > **Level** type). - - {{< figure src="/attachments/refguide/modeling/application-logic/microflows-and-nanoflows/microflows/testing/employee-entity.png" alt="A view of the Employee entity used by the sample microflow" max-width=80% >}} - -4. Create a microflow called **Promote** that changes the **Level** attribute of the **Employee** entity based on the enumeration value: - * For the **Change Employee's level to Medior** activity, set the **Level** value to *MyFirstModule.Level.Medior* - * For the **Change Employee's level to Senior** activity, set the **Level** value to *MyFirstModule.Level.Senior* - - {{< figure src="/attachments/refguide/modeling/application-logic/microflows-and-nanoflows/microflows/testing/promote-microflow.png" alt="A view of the sample Promote microflow" max-width=80% >}} - -### Creating a Unit Test +### Creating a Unit Test {#create-unit-test} This section describes how to create a microflow-based unit test for the sample microflow described in the [Creating a Sample Microflow for Testing](#sample-microflow) section above. In a real-life scenario, the steps below may be different, depending on the microflow that you want to test. For guidelines on creating unit test microflows, see the [Creating Unit Tests for Microflows](/appstore/modules/unit-testing/#creating-microflow-unit-tests) section of *Unit Testing*. -{{% alert color="info" %}}As a best practice, do not test every microflow in your application. Instead, test your most essential microflows.{{% /alert %}} - To create a sample test microflow, follow these steps: 1. In the left-side navigation pane, right-click on **MyFirstModule**, and then click **Add folder**. @@ -172,4 +225,6 @@ To create a sample test microflow, follow these steps: ## Read More +* [Testflows](/refguide/testflows/) +* [Test Runner](/refguide/test-runner/) * [Unit Testing](/appstore/modules/unit-testing/) diff --git a/content/en/docs/refguide/modeling/application-logic/microflows-and-nanoflows/nanoflows/_index.md b/content/en/docs/refguide/modeling/application-logic/microflows-and-nanoflows/nanoflows/_index.md index 27fbd52b14d..efa4c8e81e7 100644 --- a/content/en/docs/refguide/modeling/application-logic/microflows-and-nanoflows/nanoflows/_index.md +++ b/content/en/docs/refguide/modeling/application-logic/microflows-and-nanoflows/nanoflows/_index.md @@ -8,7 +8,7 @@ description: "Presents an overview of all the elements that can be used in a nan ## Introduction -Nanoflows are similar to [microflows](/refguide/microflows/), in that they allow you to express the logic of your application. However, they do have some specific benefits. For example, they run directly on a browser/device and hence can be used in an offline app. Furthermore, since most of the activities run directly on the device, there is also a speed benefit for logic which does not need access to the server. For more information on how nanoflows and microflows differ, see the [Differences between Microflows and Nanoflows](/refguide/microflows-and-nanoflows/#differences) section in *Microflows and Nanoflows*. +Nanoflows are similar to [microflows](/refguide/microflows/), in that they allow you to express the logic of your application. However, they do have some specific benefits. For example, they run directly on a browser/device and hence can be used in an offline app. Furthermore, since most of the activities run directly on the device, there is also a speed benefit for logic which does not need access to the server. For more information on how nanoflows and microflows differ, see the [Differences between Microflows and Nanoflows](/refguide/microflows-and-nanoflows/#differences) section in *Microflows, Nanoflows, and Testflows*. This page is an overview of all the elements that can be used in a nanoflow. For the properties of the nanoflow itself, see [Nanoflow Properties](/refguide/nanoflow/). diff --git a/content/en/docs/refguide/modeling/application-logic/microflows-and-nanoflows/testflows/_index.md b/content/en/docs/refguide/modeling/application-logic/microflows-and-nanoflows/testflows/_index.md new file mode 100644 index 00000000000..fc3ef407a68 --- /dev/null +++ b/content/en/docs/refguide/modeling/application-logic/microflows-and-nanoflows/testflows/_index.md @@ -0,0 +1,68 @@ +--- +title: "Testflows" +url: /refguide/testflows/ +weight: 25 +description: "Describes testflows, which you use to test the logic of your app in Studio Pro." +beta: true +--- + +{{% alert color="warning" %}} This feature is in beta. For more information, see [Release Status](/releasenotes/release-status/). {{% /alert %}} + +## Introduction + +A testflow is a document that tests the logic of your app. You build a testflow in the same way as a [microflow](/refguide/microflows/): you add activities, decisions, and loops, and you connect them with sequence flows. In addition, a testflow can contain Assert activities, which check whether the result of your logic is what you expect. + +You run testflows from the **Test Runner** pane in Studio Pro. A testflow passes when all of its Assert activities pass. It fails as soon as an Assert activity fails or another error occurs. + +Testflows are available in Studio Pro 11.18 and above. + +## Creating a Testflow {#create} + +You can only create testflows in the **Testing** node of a module. To create a testflow, follow these steps: + +1. In the [App Explorer](/refguide/app-explorer/), expand the module where you want to add the testflow. +2. Right-click the **Testing** node and select **Add testflow**. +3. Enter a name for the testflow and click **OK**. + +The testflow opens in the editor, and the **Test Runner** pane shows the new testflow. + +For naming conventions for testflows, see the [Testflows and Test Microflows](/refguide/naming-convention-best-practices/#unit-test-microflows) section in *Naming Convention Best Practices*. + +## Testflow Elements {#elements} + +A testflow can contain the same elements as a microflow, with the following differences: + +* A testflow can contain [testing activities](/refguide/activities/#testing-activities), such as the Assert activity. Testing activities are only available in testflows. +* A testflow cannot have [parameters](/refguide/parameter/). +* A testflow does not return a value. The result of a testflow is determined by its Assert activities. + +If a testflow contains an element that is not allowed, Studio Pro shows a consistency error. + +Because Studio Pro runs testflows from the **Test Runner** pane, a testflow does not need to be called from other parts of your app. Studio Pro does not report testflows as unused documents. + +## Checking Results with the Assert Activity {#assert} + +A typical testflow prepares the data it needs, calls the microflow you want to test, and then uses one or more [Assert](/refguide/assert/) activities to check the result. Each Assert activity has a Boolean target expression that must evaluate to `true`, and an optional failure result expression that describes what went wrong. + +When an Assert activity fails, the testflow stops and fails, and the **Test Runner** pane shows the failure message. A failed Assert activity always stops the testflow, so its error handling is always **Rollback**. For more information, see the [Error Handling](/refguide/assert/#error-handling) section in *Assert*. + +## Running Testflows {#run} + +You run testflows from the [Test Runner](/refguide/test-runner/) pane. To open this pane, click **View** > **Test Runner**. When you open a testflow in the editor, the **Test Runner** pane also opens and selects that testflow. + +You can run all testflows in your app, or only the testflows and modules you select. Studio Pro runs the testflows one at a time. Each testflow runs in a dedicated runtime with its own in-memory database, so testflows do not affect each other or the data of your app. If your app is running locally, Studio Pro asks you to confirm before it stops the app to run the tests. + +Testflows run without a user session, as the system user. + +## Pipelines and Deployment {#pipelines-deployment} + +When you deploy your app, its testflows are currently deployed with it, including to production environments. This will change in an upcoming 11.18 patch release, after which testflows are no longer deployed. + +You cannot run testflows in a CI/CD pipeline yet. This is on the roadmap. + +## Read More + +* [Assert](/refguide/assert/) +* [Test Runner](/refguide/test-runner/) +* [Microflows](/refguide/microflows/) +* [Testing](/refguide/testing/) diff --git a/content/en/docs/refguide/modeling/best-practices/dev-best-practices/naming-conventions.md b/content/en/docs/refguide/modeling/best-practices/dev-best-practices/naming-conventions.md index 825a1a5a42c..b8b18b9891c 100644 --- a/content/en/docs/refguide/modeling/best-practices/dev-best-practices/naming-conventions.md +++ b/content/en/docs/refguide/modeling/best-practices/dev-best-practices/naming-conventions.md @@ -172,18 +172,23 @@ To clearly identify a [sub-microflow](/refguide/extracting-and-using-sub-microfl | ------------- | --------------------------- | | Sub-microflow | SUB_{Microflow description} | -### Unit Test Microflows +### Testflows and Test Microflows {#unit-test-microflows} -Microflows containing unit tests should have the prefix **TEST_** or **UT_** (case-insensitive). For more information about the Unit Testing module, see [Unit Testing](/appstore/modules/unit-testing/). +Use a prefix that shows the type of test. This applies to [testflows](/refguide/testflows/) and to test microflows for the [Unit Testing](/appstore/modules/unit-testing/) module. [//]: # () -| Event Type | Prefix | -| ---------- | ------------ | -| Unit Test | TEST_ or UT_ | +| Test Type | Prefix | +| ---------------- | ------ | +| Unit test | UT_ | +| Integration test | IT_ | [//]: # () +{{% alert color="info" %}} +The Unit Testing module only recognizes microflows with the prefix **TEST_** or **UT_** (case-insensitive) as tests. If you use the Unit Testing module for integration tests, use the prefix **TEST_** instead of **IT_**. +{{% /alert %}} + ### Integration Microflows For integrations, you have the following types of microflow: diff --git a/content/en/docs/refguide/modeling/menus/edit-menu/preferences-dialog.md b/content/en/docs/refguide/modeling/menus/edit-menu/preferences-dialog.md index 41da3cc13ed..0c1da112b4e 100644 --- a/content/en/docs/refguide/modeling/menus/edit-menu/preferences-dialog.md +++ b/content/en/docs/refguide/modeling/menus/edit-menu/preferences-dialog.md @@ -341,7 +341,7 @@ This setting allows you to set the beta version as the default editor. In Studio Pro 11.15 and above, select **Enable orthogonal flows in the microflow, nanoflow, and rule editor** to allow rendering sequence flows as orthogonal (right-angled) lines in the microflow, nanoflow, and rule editors. When enabled, you can convert flow types between curved and orthogonal through the context menu. For more information, see the [Flow Type](/refguide/sequence-flow/#flow-type) section in *Sequence Flow*. -In Studio Pro 11.17 and above, select **Enable auto layout for microflows (Experimental)** to add an **Auto layout** option to the context menu of the microflow, nanoflow, and rule editors, which automatically arranges activities on the canvas. This setting is enabled by default. For more information, see the [Auto Layout](/refguide/microflows-and-nanoflows/#auto-layout) section in *Microflows and Nanoflows*. +In Studio Pro 11.17 and above, select **Enable auto layout for microflows (Experimental)** to add an **Auto layout** option to the context menu of the microflow, nanoflow, and rule editors, which automatically arranges activities on the canvas. This setting is enabled by default. For more information, see the [Auto Layout](/refguide/microflows-and-nanoflows/#auto-layout) section in *Microflows, Nanoflows, and Testflows*. ### Project Loading diff --git a/content/en/docs/refguide/modeling/menus/view-menu/_index.md b/content/en/docs/refguide/modeling/menus/view-menu/_index.md index 693ceef4b69..16ede3e528f 100644 --- a/content/en/docs/refguide/modeling/menus/view-menu/_index.md +++ b/content/en/docs/refguide/modeling/menus/view-menu/_index.md @@ -143,6 +143,12 @@ The **Properties** pane displays the properties of the currently selected elemen For [Team Server](/developerportal/repository/team-server/) apps, the **Stories** pane shows the [stories](/developerportal/project-management/epics/planning/) of the current [Sprint](/developerportal/project-management/epics/planning/). For more information, see [Stories Pane](/refguide/stories-pane/). +### Test Runner {#test-runner} + +{{% alert color="warning" %}} This feature is in beta. For more information, see [Release Status](/releasenotes/release-status/). {{% /alert %}} + +The **Test Runner** pane shows the [testflows](/refguide/testflows/) in your app. You can use it to run testflows and view their results. For more information, see [Test Runner](/refguide/test-runner/). + ### Toolbox {#toolbox} The **Toolbox** pane displays the tools that can be used in the current editor. For example, in a page you can insert all kinds of widgets (for example, [data containers](/refguide/data-widgets/)) by dragging them from the **Toolbox** onto your page. diff --git a/content/en/docs/refguide/modeling/menus/view-menu/test-runner.md b/content/en/docs/refguide/modeling/menus/view-menu/test-runner.md new file mode 100644 index 00000000000..a4c5ef6914d --- /dev/null +++ b/content/en/docs/refguide/modeling/menus/view-menu/test-runner.md @@ -0,0 +1,58 @@ +--- +title: "Test Runner" +url: /refguide/test-runner/ +weight: 65 +description: "Describes the Test Runner pane in Studio Pro, which you use to run testflows and view their results." +beta: true +--- + +{{% alert color="warning" %}} This feature is in beta. For more information, see [Release Status](/releasenotes/release-status/). {{% /alert %}} + +## Introduction + +The **Test Runner** pane shows the [testflows](/refguide/testflows/) in your app. You can use it to run testflows and view their results. + +To open the **Test Runner** pane, click **View** > **Test Runner**. By default, the pane is docked at the bottom of Studio Pro. When you open a testflow in the editor, or select the tab of an open testflow, the **Test Runner** pane comes to the front and selects that testflow. + +## Test Tree {#test-tree} + +The left side of the pane shows your testflows in a tree, grouped by module. Modules that do not contain any testflows are not shown. If your app does not contain any testflows, the pane shows the message **There are no tests to show.** + +Each testflow shows the result of its last run. + +## Toolbar {#toolbar} + +The toolbar contains the following buttons: + +* **Run all** – runs all the testflows in your app +* **Run** – runs the testflows and modules that you select in the tree; when you select a module, all the testflows in that module run +* **Stop** – stops the current test run +* **Reset all** – clears the results of all testflows, so that the next run starts fresh + +## Result {#result} + +The **Result** section on the right side of the pane shows the result of the testflow that you select in the tree: + +* **Success** – the testflow ran to its end without a failed [Assert](/refguide/assert/) activity or another error +* The failure message – the testflow failed, either because an Assert activity failed or because another error occurred +* **Not run yet.** – the testflow has not run yet, or its result was cleared with **Reset all** + +If an error prevents the test run itself, for example because the app cannot be deployed, Studio Pro shows the error in a dialog box. + +## How Testflows Run {#how-testflows-run} + +When you run testflows, Studio Pro does the following: + +* It runs the testflows one at a time. +* It runs each testflow in a dedicated test runtime with its own in-memory database. Testflows do not affect each other, and they do not change the data of your app. +* It runs testflows as the system user, without a user session. + +{{% alert color="warning" %}} +The test runtime uses the same ports as your app. For this reason, if your app is running locally, Studio Pro asks you to confirm that it can stop the app before it runs the tests. The app stays stopped after the test run. To start it again, click **Run Locally** or press F5. +{{% /alert %}} + +## Read More + +* [Testflows](/refguide/testflows/) +* [Assert](/refguide/assert/) +* [View Menu](/refguide/view-menu/) diff --git a/content/en/docs/refguide/testing/_index.md b/content/en/docs/refguide/testing/_index.md index 5d2c5843bf9..9ce9a62799b 100644 --- a/content/en/docs/refguide/testing/_index.md +++ b/content/en/docs/refguide/testing/_index.md @@ -17,7 +17,7 @@ Testing is a vital component when creating a Mendix application. Finding and fix The testing pyramid is a convenient way to categorize tests according to their type, cost, speed, and scope. -{{< figure src="/attachments/refguide/testing/testing-pyramid.png" class="no-border" >}} +{{< figure src="/attachments/refguide/testing/testing-pyramid.png" alt="Testing pyramid showing, from bottom to top, performance and security tests, unit tests and static code analysis, API and integration tests, and frontend, UI, and E2E tests, with the Mendix and partner offerings for each test type" class="no-border" >}} Tests at the bottom of the pyramid are generally cheaper and faster to run, giving you quicker feedback. As you move up, the scope of the tests increases, but so does their complexity and execution time. @@ -42,6 +42,7 @@ For microflows or Java actions that can be isolated, you can perform unit tests. You can use the following offerings to help with this test type: +* [Testflows](/refguide/testflows/) (beta, Studio Pro 11.18 and above) - Lets you build tests for your microflows in Studio Pro and run them in the [Test Runner](/refguide/test-runner/) pane, without installing a module. Testflows are intended to replace the Unit Testing module. * [Unit Testing](/appstore/modules/unit-testing/) - Enables developers to implement, run, and manage unit tests within the Mendix application that is being tested. * [Menditect Test Automation](/appstore/partner-solutions/mta/) - Offers a no-code, visual suite of automated regression testing tools. This solution is developed by Menditect. @@ -51,6 +52,7 @@ Integration and API testing tests the interaction between different microflows, You can use the following offerings to help with this test type: +* [Testflows](/refguide/testflows/) (beta, Studio Pro 11.18 and above) - Lets you test how microflows and modules work together. A testflow can call several microflows, and each testflow runs in a dedicated runtime with its own in-memory database. * [Menditect Test Automation](/appstore/partner-solutions/mta/) - Offers a no-code, visual suite of automated regression testing tools. This solution is developed by Menditect. ### UI Tests diff --git a/source_files/refguide/testing-pyramid/render_testing_pyramid.py b/source_files/refguide/testing-pyramid/render_testing_pyramid.py new file mode 100644 index 00000000000..6b6cd65d8f8 --- /dev/null +++ b/source_files/refguide/testing-pyramid/render_testing_pyramid.py @@ -0,0 +1,151 @@ +#!/usr/bin/env python3 +"""Render the testing pyramid image used on /refguide/testing/. + +Edit the LAYERS data below, then run: + + python3 source_files/refguide/testing-pyramid/render_testing_pyramid.py + +This writes testing-pyramid.svg next to this script and renders +static/attachments/refguide/testing/testing-pyramid.png with headless Google Chrome. +It uses only the Python standard library. +""" + +import os +import shutil +import subprocess +import sys +import tempfile +from html import escape +from pathlib import Path + +# --- Content --------------------------------------------------------------- +# Each layer is one band of the pyramid. Each row in a layer is one line: +# (test type, Mendix offerings, partner offerings). An offering cell can be a +# string or a list of strings; a list is stacked as several lines in that row. +LAYERS = [ + {"color": "#45B0E1", "shape": "trapezoid", "rows": [ + ("Frontend / UI / E2E", "", "Menditect: MTA"), + ]}, + {"color": "#83CBEB", "shape": "trapezoid", "rows": [ + ("API tests", "", "Menditect: MTA"), + ("Integration tests", "Testflows (beta)", "Menditect: MTA"), + ]}, + {"color": "#C1E5F5", "shape": "trapezoid", "rows": [ + ("Unit tests", ["Testflows (beta)", "Unit Testing Module"], ""), + ("Static code analysis", "Best-Practice Recommender", "SIG: QSM"), + ]}, + {"color": "#D0D0D0", "shape": "rectangle", "rows": [ + ("Performance", "Tracing", "Datadog"), + ("Security", "Developer Portal Findings", "SIG: QSM"), + ]}, +] +HEADERS = ("Mendix", "Partner") + +# --- Layout ---------------------------------------------------------------- +WIDTH, HEIGHT = 1070, 592 +FONT = "'Helvetica Neue', Helvetica, Arial, sans-serif" +LABEL_SIZE = 30 # Text inside the pyramid +CELL_SIZE = 21 # Text in the Mendix and Partner columns +STACK_GAP = 26 # Line distance for stacked cell text +TEXT_COLOR = "#000000" +OUTLINE = "#1A1A1A" + +HEADER_H = 46 # Height of the header row above the first layer +LAYER_H = 137 # Height of each layer +LAYER_GAP = 11 # Vertical space between layers +PYRAMID_LEFT, PYRAMID_RIGHT = 8, 488 # Width of the base of the pyramid +TOP_WIDTH = 265 # Width of the top edge of the top layer +MENDIX_X, PARTNER_X, TABLE_RIGHT = 504, 855, 1064 +MENDIX_BG, PARTNER_BG = "#F2F2F2", "#E6E6E6" + +ROOT = Path(__file__).resolve().parents[3] +SVG_OUT = Path(__file__).with_name("testing-pyramid.svg") +PNG_OUT = ROOT / "static/attachments/refguide/testing/testing-pyramid.png" + + +def layer_top(i): + return 4 + i * (LAYER_H + LAYER_GAP) + + +def text(x, y, value, size, anchor="start", weight="normal"): + return (f'{escape(value)}') + + +def cell(x, y, value): + lines = value if isinstance(value, list) else [value] if value else [] + start = y - (len(lines) - 1) * STACK_GAP / 2 + return [text(x + 20, start + n * STACK_GAP, line, CELL_SIZE) for n, line in enumerate(lines)] + + +def build_svg(): + trapezoids = [l for l in LAYERS if l["shape"] == "trapezoid"] + # The trapezoids share one slope, from TOP_WIDTH at the top to the full base at the last trapezoid. + pyramid_h = len(trapezoids) * LAYER_H + (len(trapezoids) - 1) * LAYER_GAP + center = (PYRAMID_LEFT + PYRAMID_RIGHT) / 2 + base_w = PYRAMID_RIGHT - PYRAMID_LEFT + + def half_width(y): + return (TOP_WIDTH + (base_w - TOP_WIDTH) * (y - 4) / pyramid_h) / 2 + + out = [f''] + table_bottom = layer_top(len(LAYERS) - 1) + LAYER_H + out.append(f'') + out.append(f'') + out.append(text(MENDIX_X + 20, 4 + HEADER_H / 2, HEADERS[0], CELL_SIZE + 1, weight="bold")) + out.append(text(PARTNER_X + 16, 4 + HEADER_H / 2, HEADERS[1], CELL_SIZE + 1, weight="bold")) + + for i, layer in enumerate(LAYERS): + top, bottom = layer_top(i), layer_top(i) + LAYER_H + if layer["shape"] == "trapezoid": + t, b = half_width(top), half_width(bottom) + points = f"{center - t},{top} {center + t},{top} {center + b},{bottom} {center - b},{bottom}" + out.append(f'') + else: + out.append(f'') + + rows = layer["rows"] + step = LAYER_H / (len(rows) + 1) if len(rows) > 1 else LAYER_H / 2 + for r, (label, mendix, partner) in enumerate(rows): + y = top + step * (r + 1) if len(rows) > 1 else top + LAYER_H / 2 + # Pull two-row layers slightly apart, like the original design. + if len(rows) == 2: + y = top + LAYER_H * (0.30 if r == 0 else 0.72) + out.append(text(center, y, label, LABEL_SIZE, anchor="middle")) + out += cell(MENDIX_X, y, mendix) + out += cell(PARTNER_X - 4, y, partner) + + out.append("") + return "\n".join(out) + + +def find_chrome(): + candidates = [ + "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome", + shutil.which("google-chrome"), shutil.which("chromium"), shutil.which("chrome"), + ] + for c in candidates: + if c and os.path.exists(c): + return c + sys.exit("Google Chrome not found; install it or add it to the candidates in find_chrome().") + + +def render_png(svg): + html = f"{svg}" + with tempfile.TemporaryDirectory() as tmp: + page = Path(tmp) / "pyramid.html" + page.write_text(html, encoding="utf-8") + subprocess.run([ + find_chrome(), "--headless=new", "--disable-gpu", "--hide-scrollbars", + "--force-device-scale-factor=1", f"--window-size={WIDTH},{HEIGHT}", + "--default-background-color=00000000", f"--user-data-dir={tmp}/profile", + f"--screenshot={PNG_OUT}", page.as_uri(), + ], check=True, capture_output=True) + + +if __name__ == "__main__": + svg = build_svg() + SVG_OUT.write_text(svg, encoding="utf-8") + render_png(svg) + print(f"Wrote {SVG_OUT.relative_to(ROOT)} and {PNG_OUT.relative_to(ROOT)}") diff --git a/source_files/refguide/testing-pyramid/testing-pyramid.svg b/source_files/refguide/testing-pyramid/testing-pyramid.svg new file mode 100644 index 00000000000..88bc59e574c --- /dev/null +++ b/source_files/refguide/testing-pyramid/testing-pyramid.svg @@ -0,0 +1,29 @@ + + + +Mendix +Partner + +Frontend / UI / E2E +Menditect: MTA + +API tests +Menditect: MTA +Integration tests +Testflows (beta) +Menditect: MTA + +Unit tests +Testflows (beta) +Unit Testing Module +Static code analysis +Best-Practice Recommender +SIG: QSM + +Performance +Tracing +Datadog +Security +Developer Portal Findings +SIG: QSM + \ No newline at end of file diff --git a/static/attachments/refguide/testing/testing-pyramid.png b/static/attachments/refguide/testing/testing-pyramid.png index e7f398ae0c7..47ff8a17bbc 100644 Binary files a/static/attachments/refguide/testing/testing-pyramid.png and b/static/attachments/refguide/testing/testing-pyramid.png differ