Try adding the VariableRetriever after the FeatureWriter (instead of before), so the value of the variable will be available in the Tester.
I would generally say not to use Variables. They depend on the order features are processed and can have scenarios (like this) where you don't get a value because features are not being read in the way you imagine.
Here I can think of a couple of solutions:
1) Keep the Variable transformers, but put a FeatureHolder after the VariableSetter. That will hold up features so the final variable is set before the first feature tries to fetch it back.
2) Use a StatisticsCalculator to calculate the number of features. Just pick any attribute to analyze (it doesn't matter) and use the value of the _count attribute.
As I don't recommend variables, my suggestion is for #2.
I would simply add counters with different names or same names whenever I want to sum up from different origins since it is in the same workspace.
I think @gisinnovationsb is spot on. In a single workspace, multiple Counters with the same name generate sequential numbers in a common series if they all are in the Global Scope. Therefore, in this workflow for example, if the number of features to be written is 20, the final count number in the first Counter is 19 because the Count Start has been set to 0.
Then, the count number will be 20 when the summary feature from the FeatureWriter arrived in the second Counter.
I think @gisinnovationsb is spot on. In a single workspace, multiple Counters with the same name generate sequential numbers in a common series if they all are in the Global Scope. Therefore, in this workflow for example, if the number of features to be written is 20, the final count number in the first Counter is 19 because the Count Start has been set to 0.
Then, the count number will be 20 when the summary feature from the FeatureWriter arrived in the second Counter.
Just to clarify Takashi's answer: the Counter_2 is needed after the FeatureWriter because the Summary feature does not preserve any attributes from the 'input' side. So by picking up the count after FeatureWriter you recover the _feature_count.
If you're writing to a database, use the SQLExecutor to do a COUNT(*) to the table you've written too instead of using Counter - as described
here.
StatisticsCalulator and FeatureHolder are both blocker transformers, so might have an impact on performance for larger datasets